ı need to help about Decision Branching task1 solution, I don't understand this:

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

I copied the solution and pasted in the task and clicked submit but it didn't run
@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.
Could you provide more information about your query.

Sign in to comment.

Answers (1)

if doPlot == 1
plot(x, y)
title('Plot of x vs y')
xlabel('x-axis')
ylabel('y-axis')
end

Categories

Asked:

on 18 Feb 2022

Edited:

on 25 Sep 2025

Community Treasure Hunt

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

Start Hunting!