Plot of an curve and its equation

조회 수: 1 (최근 30일)
OLuxanna
OLuxanna 2022년 11월 5일
댓글: OLuxanna 2022년 11월 5일
Hello;
I'm trying to get an equation of the plot and before trying to get this I got this plot to see if I can catch it truly and it does.
And here what I ve done till now;
x = 0 : 0.1 : 0.9;
y = [0.584459303
0.496427561
0.351841147
0.269416786
-0.080568348
0.354476019
0.155290021
0.755090485
0.612397011
0.505868478];
a=polyfit(x,y,9);
b=polyval(a,x);
plot(x,y,'ro',x,b)
And What I would like to have is the equation of this plot but once I tried to write the equation with the values from polyfit output I got a plot something completely different. May someone please help me? Thank you so much in advance..
x = 0 : 0.1 : 0.9;
y = [0.584459303
0.496427561
0.351841147
0.269416786
-0.080568348
0.354476019
0.155290021
0.755090485
0.612397011
0.505868478];
c= [214387.3975 -859079.8412 1444444.664 -1323346.187 717335.5313 -233431.4118 44018.3122 -4332.146236 165.7218241 0.584459303];
vel = c.*x';
plot(x,vel,'b','LineWidth',2)

채택된 답변

VBBV
VBBV 2022년 11월 5일
편집: VBBV 2022년 11월 5일
x = 0 : 0.1 : 0.9;
y = [0.584459303
0.496427561
0.351841147
0.269416786
-0.080568348
0.354476019
0.155290021
0.755090485
0.612397011
0.505868478];
a=polyfit(x,y,9)
a = 1×10
1.0e+06 * 0.2144 -0.8591 1.4444 -1.3233 0.7173 -0.2334 0.0440 -0.0043 0.0002 0.0000
b=polyval(a,x)
b = 1×10
0.5845 0.4964 0.3518 0.2694 -0.0806 0.3545 0.1553 0.7551 0.6124 0.5059
plot(x,y,'ro',x,b)
x = 0 : 0.1 : 0.9;
y = [0.584459303
0.496427561
0.351841147
0.269416786
-0.080568348
0.354476019
0.155290021
0.755090485
0.612397011
0.505868478];
c= [214387.3975 -859079.8412 1444444.664 -1323346.187 717335.5313 -233431.4118 44018.3122 -4332.146236 165.7218241 0.584459303];
vel = max(b.*x')
vel = 1×10
0.5260 0.4468 0.3167 0.2425 0 0.3190 0.1398 0.6796 0.5512 0.4553
plot(x,vel,'b-','LineWidth',2)
  댓글 수: 2
VBBV
VBBV 2022년 11월 5일
use pol2sym to get equation for the plot
OLuxanna
OLuxanna 2022년 11월 5일
thank you so much Sir for your help. It means a lot.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by