ı need to help about Decision Branching task1 solution, I don't understand this:
Show older comments
Modify the script so that the plotting code on lines 5-8 are executed only when doPlot is 1.
The solution shows that:
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end
but when ı click submit,it isn't true.
7 Comments
Jan
on 18 Feb 2022
What does "it isn't true" mean?
Ummu Gulsum Simsek
on 18 Feb 2022
Jan
on 18 Feb 2022
@Ummu Gulsum Simsek: Please remember, that we cannot read your mind :-)
You pasted this code where? What do you see, which lket you assume, that "it didn't run"?
The code snippet looks fine, but we do neither see the complete code nor the error message. We do not know, in which service you want to paste the code and cannot know, what "doPlot" is. If it is e.g. the empty matrix [], the conmparison must fail. Use if isequal(doPlot, 1) instead.
Prateek Rai
on 21 Feb 2022
Edited: Prateek Rai
on 21 Feb 2022
Could you provide more information about your query.
Hassan Iskandarani
on 25 Feb 2022
same problem
Hassan Iskandarani
on 25 Feb 2022
Edited: Walter Roberson
on 25 Sep 2025
Hassan Iskandarani
on 25 Feb 2022
Edited: Walter Roberson
on 25 Sep 2025
NVM it worked
Answers (1)
Sabyrzhan
on 25 Sep 2025
if doPlot == 1
plot(x, y)
title('Plot of x vs y')
xlabel('x-axis')
ylabel('y-axis')
end
Categories
Find more on Search Path in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!