the plot is not appearing what should i fix ?
3 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (1 件)
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);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!