How can I graph several points from a table and extrapolate a curve?

조회 수: 1 (최근 30일)
Stephen
Stephen 2013년 12월 9일
댓글: Stephen 2013년 12월 9일
I'm somewhat new to MATLAB, although I used it in school. I have a table of x and y-values, and want to plot the points on a graph and then extrapolate a linear curve. Can someone help explain how to do this? I am used to graphing with equations, this is sort of the opposite way around.

채택된 답변

dpb
dpb 2013년 12월 9일
Well, poly[fit|val] are "all in Matlab"...
dat=[1500,200; 2500,259; 4530,1980];
plot(dat(:,1),dat(:,2))
p=polyfit(dat(:,1),dat(:,2),1);
yhat=polyval(p,[1000 5000]);
hold on
plot([1000 5000],yhat)

추가 답변 (1개)

dpb
dpb 2013년 12월 9일
A) doc plot
B) doc polyfit % and polyval
  댓글 수: 1
Stephen
Stephen 2013년 12월 9일
Thank you. If I'm looking more to do it all in matlab, then, say I'm starting at a data range like
x=1000:10:5000; y=0:.5:2000;
and I want to plot several points, say (1500,200) (2500,259) and (4530,1980) and then apply the polyfit % and polyval functions. How would I accomplish something like that?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by