13.2 判定分岐 追加の練習
显示 更早的评论
elseif キーワードを if の後に使用すると、条件を追加できます。elseif ブロックは複数含めることができます。
密度を表示するかどうかを切り替える変数 doDisplay を追加してみてください。この条件は elseif ブロックと共に追加します。
doDisplayはどういう変数なのでしょうか?ヘルプに記載がなく下記の入力ではdoPlotが0の時にエラーが表示されます.
if doPlot
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
elseif doDisplay
else
disp("The density of " + element ...
+ " is " + density)
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!