Question
matlap


3, Programmi ng Polynomial interpolation has been known sample points are plotted ys different ways (at least two) resulting
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Given the data points (xs,ys), we plot the curve at the data points in x using Matlab code below:

Required Matlab code with explanatory comments is below:

START CODE

ys=[0 0.9 0.6 1 0 0.1 -0.3 -0.7 -0.9 -0.2]; %y sample points
xs=0:length(ys)-1; %x sample points
x=0:0.1:length(ys)-1; %x data points
p3=polyfit(xs,ys,3); %fit third degree polynomial to (xs,ys)
p7=polyfit(xs,ys,7); %fit seventh degree polynomial to (xs,ys)
plot(xs,ys,'ro'); %plot sample points as red dots
hold on
plot(x,polyval(p3,x),'b--'); %plot as blue dashed lines
plot(x,polyval(p4,x),'g--'); %plot as green double dashed lines
legend('Sample points','3rd degree polynomial', '7th degree polynomial', 'Location', 'NorthEast') %add a legend

END CODE

Resulting plot is below:

1 C Sample points 0.8 3rd degree polynomial 7th degree polynomial 0.6 0.4 0.2 0. -0.4 -0.6 -0.8 -1 4 0 1 2 3 5 6 7 8 N

\blacksquare

Please do rate this answer positively if you found it helpful. Thanks and have a good day!

Add a comment
Know the answer?
Add Answer to:
matlap 3, Programmi ng Polynomial interpolation has been known sample points are plotted ys different ways...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT