the plot is not appearing what should i fix ?
4 次查看(过去 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!