MATLAB Answers

Matlabonramp 13.2.

43 views (last 30 days)
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


Sign in to comment.

Accepted Answer

Cris LaPierre
Cris LaPierre on 22 Sep 2020
"Toggle" means to switch between to states (on/off, yes/no, in/out, show/hide, etc).
A Further Practice section is an area to practice what you have learned. Here, you are provided with a suggestion of what you could do. The suggestion is to replace "else" with "elseif". This creates the opportunity to test a second condition, doDisplay. Follow the same steps you used to create the first condition, doPlot.


Rola Helwa
Rola Helwa on 22 Sep 2020
so now my code looks like this
but how do I toggle densities
I'm sorry but I still don't understand how to do the task
if doPlot==1
title("Sample Densities")
ylabel("Density (g/cm^3)")
Cris LaPierre
Cris LaPierre on 23 Sep 2020
Follow the same steps you used to create the fist condition.
if doPlot==1
<your code here>
elseif doDisplay==1
<you code here>

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!