Write a function that will receive x and y vectors representing data points. The function will create, in one Figure Window, a plot showing these data points as circles and also in the top
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:14| Question number:21.14
All Answers
total answers (1)
fitLineWidth.m
function fitLineWidth(x,y)
% Plots data points with order 2 and 3
% polynomials fit through them, with line
% widths and color specified
% Format of call: fitLineWidth(x,y)
% Does not return any values
subplot(2,1,1)
coefs = polyfit(x,y,2);
curve = polyval(coefs,x);
plot(x,y,'o',x,curve,'LineWidth',3,'Color',[0.5 0.5 0.5])
title('Second order')
subplot(2,1,2)
coefs = polyfit(x,y,3);
curve = polyval(coefs,x);
plot(x,y,'o',x,curve,'LineWidth',2, 'Color', [0 0 1])
title('Third order')
end
need an explanation for this answer? contact us directly to get an explanation for this answer