Vector error when using plot function

11 ビュー (過去 30 日間)
N/A
N/A 2020 年 12 月 4 日
コメント済み: Star Strider 2020 年 12 月 4 日
Hello, I am trying to plot the following and keep receiving an eror on plot((V1:0.1:Vmax),nmax) stating:
Error using plot - Vectors must be the same length.
Error in maybeFinal (line 285)
plot((V1:0:Vmax),nmax)
this is my code, would someone be able to help me please :
nmax = 3.8;
nmin = -1.5;
V1=((nmax*2*W)/(C_Lmax*rho1*S))^(1/2);
V2=((nmin*2*W)/(C_Lmax*rho1*S))^(1/2);
Vpos=[0:V1];
Vneg=[0:V2];
q = 30.42;
n1=(C_Lmax*rho1*S*Vpos.^2)/(2*W);
n2=(C_Lmax*rho1*S*Vneg.^2)/(2*W);
Vmax=((2*q)/rho1)^(1/2);
% Plotting Vn diagram %
plot(Vpos, n1)
hold on
plot(Vneg, n2)
hold on
plot((V1:0.1:Vmax),nmax)
hold on
plot([V2:.1:Vmax],nmin)
hold on
plot(Vmax,[nmin:.01:nmax])
% Labeling Vn Diagram %
gtext ('Positive Stall Limit')
gtext ('Negative Stall Limit')
gtext ('Positive Structural Limit')
gtext ('Negative Structural Limit')
xlabel ('Calibrated Airspeed, ft/sec')
ylabel ('Load Factor, n')

回答 (1 件)

Star Strider
Star Strider 2020 年 12 月 4 日
This:
plot((V1:0:Vmax),nmax)
creates an empty vector for the independent variable vector, since there is an increment (or step) of 0.
I suspect that you intended to replicate this plot call:
plot((V1:0.1:Vmax),nmax)
instead.
  2 件のコメント
N/A
N/A 2020 年 12 月 4 日
Thank you!
I used the correction that you provided and still receive the same error.
Star Strider
Star Strider 2020 年 12 月 4 日
My pleasure!
Try something like this:
Vvct = linspace(V1, Vmax, numel(nmax));
This assumes ‘nmax’ is a vector.
If it is a matrix, choose the dimension (rows=1 or columns=2) that you want as the independent variable, and change it to:
Vvct = linspace(V1, Vmax, size(nmax,1));
for example, with this plotting across the columns as a function of the rows. The plot function automatically uses the other dimension as the independent variable, if they are different. With a square matrix, it may be necessary to transpose it to get the correct plot.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by