How come I can't plot this?

1 回表示 (過去 30 日間)
Maclane Keohane
Maclane Keohane 2018 年 9 月 17 日
回答済み: Walter Roberson 2018 年 9 月 17 日
x1=0:100:1000;
y1=0;
x2=1000:100:2014.85;
y2=((2014.85/2106.91)*x);
x3=2014.85:100:4029.7;
y3=(-2014.85/2106.91)*x+616;
x=[x1 x2 x3];
y=[y1 y2 y3];
plot(x,y)
%I receive this error:
Error using plot
Vectors must be the same length.
Error in MacLab2 (line 29)
plot(x,y)
%How do I fix this error?

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 9 月 17 日
x1=0:100:1000;
y1=zeros(size(x1));
x2=1000:100:2014.85;
y2=((2014.85/2106.91)*x2);
x3=2014.85:100:4029.7;
y3=(-2014.85/2106.91)*x3+616;
x=[x1 x2 x3];
y=[y1 y2 y3];
plot(x,y)

カテゴリ

Help Center および File Exchange2-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