13.2 判定分岐 追加の練習
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!