I'm trying to create a graph but the code is getting teh error above.
x = [3.15647 4.15647 5.15647 6.15647 7.15647]; y = [4.15280 5.88409 7.81539 5.24301 4.09266];
plot(x,y,'o'); hold on
xa = linspace(0, 0.5, 10) ya = 4.15+(1.73.*(x-3.15))+(0.1.*(x-3.15).*(x-4.15)); plot(xa,ya,'-');

답변 (2개)

Star Strider
Star Strider 2018년 1월 27일

0 개 추천

You probably want to use ‘xa’ rather than ‘x’ in your ‘ya’ calculation:
ya = 4.15+(1.73.*(xa-3.15))+(0.1.*(xa-3.15).*(xa-4.15));
Rik
Rik 2018년 1월 27일

0 개 추천

You used the variable x in your definition of ya, which results in xa being length 10 and ya being length 5.
x = [3.15647 4.15647 5.15647 6.15647 7.15647];
y = [4.15280 5.88409 7.81539 5.24301 4.09266];
xa = linspace(0, 0.5, 10);
ya = 4.15+(1.73.*(xa-3.15))+(0.1.*(xa-3.15).*(xa-4.15));
plot(x,y,'o',xa,ya,'-')
(Also, next time, select your code and push the {}Code button to correctly format your code)

카테고리

도움말 센터File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

질문:

2018년 1월 27일

답변:

Rik
2018년 1월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by