MATLAB Answers

Stuck at MATLAB Onramp

148 views (last 30 days)
Darko Radakovic
Darko Radakovic on 19 Apr 2020
Commented: Walter Roberson on 19 May 2020
Hey guys.
I'm stuck on the self-paced MATLAB Onramp course. The section is 13.2 Decision Branching and I'm at Furher Practice. I have no idea how I'm supposed to add the "elseif" statement with "doDisplay". Can anyone show me thier take on this problem?

  3 Comments

Sneham Shrikant Vaidya
Sneham Shrikant Vaidya on 16 May 2020
if doPlot
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp("The density of" + element + "is" + density)
end
//just paste this code
or remove the dashed line in front of element is soluttion
Anushka Tilekar
Anushka Tilekar on 19 May 2020
Is the MATLAB Onramp course available free of cost ? Will I get a certificate of completion after finishing it ?
Walter Roberson
Walter Roberson on 19 May 2020
Yes, and Yes.

Sign in to comment.

Answers (1)

Vimal Rathod
Vimal Rathod on 26 Apr 2020
Hi,
The question is a bit ambiguos at start but if you look at the code carefully you will understand the each step.
It asks you to create a "doDisplay" variable, you can do that by creating a variable same as doPlot below the doPlot variable.
doPlot = randi([0 1]);
doDisplay = randi([0 1]);
It asks you to add an elseif block which can toggle whether it can display the densities or not.
if doPlot
...
elseif doDisplay
%Print the densities
else
%Print nothing just leave it with a comment for readability.
end

  1 Comment

Anushka Tilekar
Anushka Tilekar on 19 May 2020
Is the MATLAB Onramp course available free of cost ? Will I get a certificate of completion after finishing it ?

Sign in to comment.

Tags