Hello everyone. I'm trying to plot first , second and third order functions on the same graph. heres what i have so far. Its only giving me the last function. Any help would be much appreciated

조회 수: 1 (최근 30일)
x=[-4:0.5:2.5]
y =[0.0013 0.0026 0.0052 0.0106 0.0213 0.0429 0.0863 0.1738 0.3500 0.7048 1.4193 2.8582 5.76556 11.5904]
%n = input('enter order')
n=3
m= 1:1:n
for i=length(m)
[fx,a] =curvepoly(x,y,m(i));
end
y2 = polyval(a,x)
plot(x,y,'o',x,y2)

답변 (1개)

Jim Riggs
Jim Riggs 2019년 3월 21일
Try this:
figure;
plot(x,y,'r');
hold on;
plot(x,y2,'b');
In the plot command(s) replace the 'r' and the 'b with whatever plot formatting you want.

카테고리

Help CenterFile Exchange에서 Directed Graphs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by