Matlabonramp 13.2.
古いコメントを表示
The elseif keyword can be used after if to add more conditions. You can include multiple elseif blocks.Try adding a variable doDisplay to toggle if the densities are displayed. Add this condition with an elseif block.
I don't really understand or know what to write and what the task wants. What does mean "to toggle" here mean?
This is the furhther practice from the Matlab Onramp course chapter 13
採用された回答
その他の回答 (4 件)
Merel Cook
2020 年 11 月 12 日
0 投票
Now help with 13.2. I am receiving the error code, "are densities displayed when doPlot is 0". What does this error code mean?
4 件のコメント
Cris LaPierre
2020 年 11 月 12 日
This isn't an error code. It's feedback. It is a question to ask yourself about the behavior of your code. When the variable doPlot=0, do the densities appear in the plot? Look at the task and determine if they should/shouldn't be appearing and adjust your code accordingly.
Merel Cook
2020 年 11 月 13 日
Thank you for comment. However, the solution to my problem was that I didn't have the correct spacing bewteen quotation mark when I duplicate the solution ,for 13.2, provided by Matlab. I was able to reseach Matlab's answer because for this particlur problem this seems to be a common problem. I still don't understand why it provides that feedback .statement.
Cris, is there a place we can suggest the tutorial question be reworded for clarification? I didn't understand what the task required either, and from a Google search there are others in the same position. It's been a very clear and understandle onramp tutorial so far - just struggling with this part. Thank you
Cris LaPierre
2020 年 11 月 17 日
At the top right of the course, there is a question mark icon. Click on that and select "Contact Support".
From there you can create a service request, which allows you to provide suggestions back to MathWorks. Anything you put there will get to the course creator for their consideration. Be sure to be specific on what is causing the confusion.
Remember that for Tasks you can always click "See Solution". Once you understand what the solution is, it would be great if you could share what better wording might be, or what had led you to interpret the question differently than what was intended.
Mohammad Ali
2021 年 6 月 5 日
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
elseif doDisplay == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp("The density of " + element ...
+ " is " + density)
end
Vikas Chelluru
2022 年 7 月 12 日
doPlot = randi([0 1])
doDisplay=randi([0 1]
load datafile
density = data(:,1)
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
elseif doDisplay ==1
disp("The density of "+ element+ " is " + density)
end
Durga
2025 年 11 月 9 日
0 投票
doPlot = randi([0 1])
doDisplay=randi([0 1]
load datafile
density = data(:,1)
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
elseif doDisplay ==1
disp("The density of "+ element+ " is " + density)
end
カテゴリ
ヘルプ センター および File Exchange で Adding custom doc についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!