University of Science and Technology of Hanoi
Course: Numerical Methods
CURVE FITTING PROBLEMS
I. Curve fitting
Exercise 1.
The table below gives the weight and the JHI number (Jonash Health Indicator) of each student
in a class. Use it to predict the JHI number of Van Lam whose weight is 72kg.
Student Weight (kg) JHI
Lan Anh 40 1450
Van Toan 63 3817
Quang Hai 62 3708
Xuan Truong 68 4300
Cong Phuong 64 3950
Huyen My 45 1896
My Linh 50 2339
Duc Chinh 66 4200
Phan Van Duc 67 4312
1. Use function “fit()” in matlab. Plot results
2. Use function “polyfit()” in matlab. Plot results
3. Use function “lsqcurvefit()” in matlab. Plot results
4. Give some comments for the differences among these 3 methods.
Exercise 2.
Given the decaying equation of a Kagawa’s particle:
y = exp(-t.x)+0.8 and a recorded table of observation:
x y
0.1 1.6781
0.2 1.5711
0.3 1.4771
0.4 1.3945
0.5 1.3220
0.6 1.2584
0.7 1.2025
0.8 1.1535
0.9 1.1104
1.0 1.0725
a. Find the decaying rate t by function “lsqnonlin()” in matlab. Plot results.
b. Try to use lb, ub, options in: x = lsqnonlin(fun,x0,lb,ub,options)
Exercise 3.
Given a table of observation:
x f(x)
0.00000 0.00000
0.78540 0.70711
1.57080 1.00000
2.35619 0.70711
3.14159 0.00000
3.92699 -0.70711
4.71239 -1.00000
5.49779 -0.70711
6.28319 0.00000
a. Calculate f(3.00000) and f(4.50000) by function “interp1()” in matlab. Plot results.
b. Try to use another method (‘nearest', 'cubic', or 'spline'.) with vq = interp1(x,v,xq,method)
Exercise 4.
Given x runs from -3 to 3 with step of 1 and so does y.
1. Draw a grid of coordinates of (x,y) (hint: meshgrid)
2. Build a random function z having many local extremes that takes only 2 arguments x and y. (hint:
peaks)
3. Compute z(1.2, 2.8) and z(2.5, 2.5) by function “interp2()”
II. Common
Exercise 1. Find the eigenvalues and eigenvectors of the following matrix
Exercise 2. Plot data
Try to use: