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

回答(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 CenterFile Exchange 中查找有关 Graphics Objects 的更多信息

产品


版本

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by