Plotting for a Loop
1 回表示 (過去 30 日間)
古いコメントを表示
I'm not an experienced Matlab user, but I'm trying to learn. I'm having a problem with plotting the results from my loop. It shows me the graph but there is no data populated in it. Does anybody no have to fix this?
for a=(0:0.01:0.3333333)
C_T=4*a*(1-a)*etaTipLoss
C_P=4*a*(1-a)^2*etaTipLoss*etaDrag
figure(1); plot(a,C_P, "-.r"); hold on
end
0 件のコメント
採用された回答
Bob Thompson
2021 年 2 月 1 日
Each time you run the plot command you're only plotting a single point, which doesn't work very well with plot.
I recommend you switch to scatter instead, or index C_p for the loop and run plot outside the loop once.
for a=(0:0.01:0.3333333)
C_T=4*a*(1-a)*etaTipLoss
C_P=4*a*(1-a)^2*etaTipLoss*etaDrag
figure(1); scatter(a,C_P, "-.r"); hold on
end
% or
idx = 0;
for a=(0:0.01:0.3333333)
idx = idx + 1;
C_T=4*a*(1-a)*etaTipLoss
C_P(idx) =4*a*(1-a)^2*etaTipLoss*etaDrag
end
figure(1); plot([0:0.01:0.3333333],C_P, "-.r")
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!