the plot is not appearing what should i fix ?

3 ビュー (過去 30 日間)
poorya gholamnejad
poorya gholamnejad 2022 年 8 月 4 日
回答済み: Walter Roberson 2022 年 8 月 5 日
g=9.81;
Flow = app.FlowEditField.Value;
Width = app.WidthEditField.Value;
q = Width/Flow;
yc=(q^2/g)^(1/3);
Criticaldepth = app.CriticalDepthEditField.Value;
app.CriticalDepthEditField.Value = [num2str(yc)];
Depth = app.DepthEditField.Value;
for i=1:length(Depth)
E(i)=Depth(i)+q^2/(2*g*Depth(i)^2);
plot(app.UIAxes,E,Depth,'r');
end

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 8 月 5 日
for i=1:length(Depth)
E(i)=Depth(i)+q^2/(2*g*Depth(i)^2);
end
plot(app.UIAxes,E,Depth,'r');
However, the convention is that the independent variable (Depth in this case) should be on the horizontal axes (first data parameter) and that the dependent variable (E in this case) should be on the vertical axes. It will be confusing to people that you have those reversed.
Note: instead of the loop you could vectorize to
E = Depth + q^2 ./ (2*g*Depth.^2);

カテゴリ

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

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by