Decision Branching, modification Script

54 次查看(过去 30 天)
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 个评论
Muhammad Mansoor khan
Reenter this code
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end

请先登录,再进行评论。

回答(9 个)

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

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

Manisha Sonewane
Manisha Sonewane 2021-9-29
If doPlot==1 %%plotting code; end

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

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

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

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

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

Hojiboy
Hojiboy 2023-5-15
if doPlot == 1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
end
  2 个评论
Niklas
Niklas 2023-9-12
All answers above will lead to:
Test Results:
Incorrect!
When doPlot is 0, did you not plot the data?
PUJA
PUJA 2024-4-20,9:56
编辑:PUJA 2024-4-20,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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by