Question: Use a separate Matlab script to perform the following: Load the datasets, and plot them in separate figures using Matlab s scatter plotting function. Which

Use a separate Matlab script to perform the following:
Load the datasets, and plot them in separate figures using Matlabs scatter plotting function.
Which basis function is appropriate? (trig or poly)
Should you use approximation or interpolation? J
Use your func_fit function to perform both approximation and interpolation on the given datasets
Plot the approximator and interpolant with different colors on top of the scatter plot of each dataset.
data:(in test.txt)
X1=[1.1,2.2,3.3,4.4,0.5]
Y1=[0.1,1.2,2.3,3.4,4.5]
X2=[0.5,1.5,2.5,3.5,4.5]
Y2=[4.5,3.5,2.5,1.5,0.5]
funfit:
function [coefficient_vector]= func_fit(X,Y,type,basis,parameters)
if contains(type, 'approximate')
if contains(basis, 'poly')
m = parameters;
X_design = ones(length(X), m+1);
for i =1:m
X_design(:, i+1)= X.^i;
end
results = X_design' * X_design;
results = results \(X_design' * Y);
coefficient_vector = results;
return
elseif contains(basis, 'trig')
X_trig =[sin(X), cos(X)];
result2= X_trig' * X_trig;
result2s = result2\(X_trig' * Y);
coefficient_vector = result2s;
return
end
elseif contains(type, 'interpolate')
if contains(basis,'poly')
x_transpose = X';
result = x_transpose * X;
results = result \ x_transpose * Y;
coefficient_vector = results;
return
elseif contains(basis, 'trig')
X_trig =[sin(X), cos(X)];
result1= X_trig' * X_trig;
result1s = result1\(X_trig' * Y);
coefficient_vector = result1s;
return;
end
end
end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!