Don't know why it is showing incorrect?

I get an incorrect mark in the task(2) of 13.2 section of Matlab onramp course.Even if i saw the solution in the see solution option and entered the same the error still shows.
the task is given below:
Modify the script so that when the if condition is not satisfied, the following line of code is executed:
disp("The density of " + element ...
+ " is " + density)

6 Commenti

Hi Varun,
Make sure if you included the condition correctly. A screenshot about the issue will help.
% For example, taking random values, as the values and condition is not known
element = 1;
density = 10;
cond = 0;
if ~(cond)
disp("The density of " + element ...
+ " is " + density)
end
This should work.
Can you once try in the above lines and do let know?
Regards,
Sriram
I have also face the same problem. Also use above code but still facing the same error
error is: "Are the densities displayed when doPlot is 0?"
@ Sriram Sir, i am facing the same problem too. it isn"t working!
I just did try now and it works again.
Can you share your code that you tried? If possible even the screenshot showing the error of onramp.
i am facing same problem
if doPlot
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
x=("The density of " + element ...
+ " is " + density)
disp(x)
plot=[];
end

Accedi per commentare.

 Risposta accettata

ravi meena
ravi meena il 12 Apr 2020
Modificato: Image Analyst il 12 Apr 2020
It will work when you enter the code carefully. For example, if you will enter
disp("The density of" + element...
+ " is " + density )
it will not work but, instead of this enter
disp("The density of " + element...
+ " is " + density )
there is a space after of and it will work.

9 Commenti

But the space after the "of" has no bearing on if the program will get to the disp() line of code. It only affects what the code looks like. Sriram's code should work. However if the answer checking looks for an exact character by character match in the command window then the space would be necessary. I'm/we're just not sure how they determine if the disp() line was arrived at.
write the sentense as it is with correct spaces
Image Analyst, from the failures people have been posting about on Answers this task checks that the line of code displays exactly the message (with spaces) displayed by that sample disp statement.
I'll report this confusion to the MATLAB Onramp team -- maybe there's some way we can make the result message clearer when the student's code displays a message but displays it without spaces.
I am facing the same problem , should i consider it correct for myself or i shoud keep trying?
The question posted says,
"Modify the script so that when the if condition is not satisfied, the following line of code is executed:"
You should be copying the exact line of code they provide. The students who used (for example)
disp("The density of" + element...
+ " is " + density )
are not using the required line of code, because the required line of code has a space after the "of" .
Thanks man it worked
Im still facing the problem
We do not know what code you are using.
thank you, it works

Accedi per commentare.

Più risposte (3)

Ryan Leman
Ryan Leman il 2 Mag 2020
Modificato: Ryan Leman il 2 Mag 2020
Just letting everyone know that I am having the same kind of issue on audio frequency tasks.
I even clicked on "see solution" and copy & pasted the entire thing so my version and the solution are identical. I submitted a report about this a few minutes ago w/ screen shot. I also noticed that it takes a little bit longer than usual to load the whole incorrect answer thing, maybe there is a bug causing it to timeout?

1 Commento

Ryan Leman
Ryan Leman il 2 Mag 2020
Modificato: Ryan Leman il 2 Mag 2020
little more info that might be relevant. My internet connection is fine however I did ping the host and got this.
Update: It seems to be working now, it finally let me pass. I think there might be some server silliness going on atm. I pinged it again at the time Onramp was working correctly and the ping was fine this time around. However a did it again a few moments after and got the same message as the picture below (the picture was from my original comment). This might also support the server silliness hypothesis.

Accedi per commentare.

Kumar Shubham
Kumar Shubham il 12 Ago 2020
insert the spaces properly especially after of.
if doPlot==1
plot(density)
title("Sample Densities")
xticklabels(element)
ylabel("Density (g/cm^3)")
else
disp("The density of " + element ...
+ " is " + density)
end

Categorie

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by