vectors must be the same length
古いコメントを表示
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
2018 年 1 月 27 日
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
2018 年 1 月 27 日
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 についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!