Decision Branching, modification Script

54 views (last 30 days)
Francis Adams Kwofie
Francis Adams Kwofie on 5 Jul 2021
Edited: PUJA on 20 Apr 2024 at 10:01
Modify the script so that the plotting code on lines 4-7 are executed only when doPlot is 1.
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
  2 Comments
Muhammad Mansoor khan
Muhammad Mansoor khan on 7 Sep 2022
Reenter this code
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

Sign in to comment.

Answers (9)

Dhruv G
Dhruv G on 5 Jul 2021
if doPlot
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

KAPIL DEV YADAV
KAPIL DEV YADAV on 10 Jun 2022
if doPlot==1
plot(5,8)
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

Manisha Sonewane
Manisha Sonewane on 29 Sep 2021
If doPlot==1 %%plotting code; end

Harshada Pawar
Harshada Pawar on 9 Jan 2022
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")

Thameemul Ansari Kaja
Thameemul Ansari Kaja on 17 Jan 2022
if doPlot==1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

Samuel Kwesi Tandoh
Samuel Kwesi Tandoh on 30 Mar 2022
if doPlot==1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

chaymae saibari
chaymae saibari on 3 Apr 2022
if doPlot==1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

Hashim Albasher
Hashim Albasher on 1 Feb 2023
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

Hojiboy
Hojiboy on 15 May 2023
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end
  2 Comments
Niklas
Niklas on 12 Sep 2023
All answers above will lead to:
Test Results:
Incorrect!
When doPlot is 0, did you not plot the data?
PUJA
PUJA on 20 Apr 2024 at 9:56
Edited: PUJA on 20 Apr 2024 at 10:01
Modify the script so that the plotting code on lines 5-8 execute only if doPlot is 1.
Answer:
if doPlot == 1
x=5
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

Sign in to comment.

Categories

Find more on Line Plots in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!