Decision Branching, modification Script

182 views (last 30 days)
Francis Adams Kwofie
Francis Adams Kwofie on 5 Jul 2021
Commented: Muhammad Mansoor khan on 7 Sep 2022 at 15:15
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 at 15:15
Reenter this code
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

Sign in to comment.

Answers (7)

Dhruv G
Dhruv G on 5 Jul 2021
if doPlot
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
  1 Comment
bhuvan lekkala
bhuvan lekkala on 10 Nov 2021
this is wrong and its shows errors and its just a hint

Sign in to comment.


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

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

Tags

Products

Community Treasure Hunt

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

Start Hunting!