MATLAB Answers

Decision Branching Error in matlab onramp

58 ビュー (過去 30 日間)
Girish K
Girish K 2019 年 12 月 2 日
コメント済み: Attilio Pallage Don 2021 年 3 月 12 日 22:34
How to crack this error? The input data and solution provided by the matlab sources are same still the error is occuring.
  4 件のコメント
Walter Roberson
Walter Roberson 2020 年 7 月 13 日
disp("The density of " + element + " is " + density)
Notice the space needed after "of"

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2019 年 12 月 2 日
That might be checking that the densities that are printed as text when doPlot is 0 exactly match the densities that would be printed by "the code as shown above". The code you're using doesn't exactly match: note that your code doesn't display a space between "of" and the name of the element. Try adding the spacing before and after the element name (as I believe "the code as shown above" does) and see if that allows you to pass the test case.
  4 件のコメント
Damilola Adeniji
Damilola Adeniji 2019 年 12 月 18 日
Hi Steve
Thanks for the quick response.
Even after following the phrase is still saying incorrect.
thanks.
Capture.PNG

サインインしてコメントする。

その他の回答 (5 件)

Ivan Derkunskii
Ivan Derkunskii 2020 年 3 月 8 日
You'll be laughing, but you need just put spaces inside the phrases "The density of the" and "is" so that they look like "The density of the " (a space after the whole phrase) and " is " (spaces before and after the word).
  6 件のコメント
Rupesh Shrestha
Rupesh Shrestha 2020 年 8 月 4 日
HAHAHAHAHA Exactly!!!!
I tried putting spaces too but I had missed one space. Then again I tried with spaces in all places, it finally works.
if doPlot
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp(" The density of " + element ...
+ " is " + density)
end

サインインしてコメントする。


Bongani Tavengwa
Bongani Tavengwa 2020 年 6 月 4 日
if doPlot
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp("The density of" + element + "is" + density)
end
  3 件のコメント
Steven Lord
Steven Lord 2020 年 6 月 4 日
name = "Bongani Tavengwa";
disp("Do you see the problem now" + name)
disp("Do you see the problem now " + name)
Do you see the difference in the two displayed statements? What's the difference between the second and third lines of code and what impact does that difference have in the displayed text?

サインインしてコメントする。


Sreekanth K M
Sreekanth K M 2020 年 6 月 17 日
if doPlot
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp(" The density of " + element + " is " + density)
end
  2 件のコメント
Steven Lord
Steven Lord 2020 年 9 月 24 日
Without seeing what you tried we can't determine why what you tried isn't working.

サインインしてコメントする。


Surya Karthik Nadupalle
Surya Karthik Nadupalle 2020 年 8 月 22 日
編集済み: Surya Karthik Nadupalle 2020 年 8 月 22 日
The problem is solved only when you give gaps between words in the bracket. Notice the spacing i gave. It worked
disp(" The density of " + element + " is " + density)
  1 件のコメント
Milagros Walker
Milagros Walker 2020 年 9 月 24 日
still di not work

サインインしてコメントする。


1805645
1805645 2021 年 1 月 20 日
Hey, I have the same problem. How should I fix it?
  1 件のコメント
Attilio Pallage Don
Attilio Pallage Don 2021 年 3 月 12 日 22:34
just clear the default code in task 1&2, then try the code......!!!!!!

サインインしてコメントする。

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by