Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 funcfit 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
X
Y
X
Y
funfit:
function coefficientvector funcfitXYtype,basis,parameters
if containstype 'approximate'
if containsbasis 'poly'
m parameters;
Xdesign oneslengthX m;
for i :m
Xdesign: i Xi;
end
results Xdesign' Xdesign;
results results Xdesign' Y;
coefficientvector results;
return
elseif containsbasis 'trig'
Xtrig sinX cosX;
result Xtrig' Xtrig;
results resultXtrig' Y;
coefficientvector results;
return
end
elseif containstype 'interpolate'
if containsbasis'poly'
xtranspose X;
result xtranspose X;
results result xtranspose Y;
coefficientvector results;
return
elseif containsbasis 'trig'
Xtrig sinX cosX;
result Xtrig' Xtrig;
results resultXtrig' Y;
coefficientvector results;
return;
end
end
end
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started