in cody coursework i keep getting the response "Assertion failed." when i go to test the question. What am i doing wrong?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
TAPAN DARJI
am 30 Jan. 2017
Kommentiert: Nicholas Ayres
am 13 Jun. 2017
product of y and z such that the result is a 40x5 matrix?
y=linspace(2.5,10,5)'
z=ones(1,40)
z(1,1:40)=pi
y*z= 5x40 matrix=M
When I try to use the inverse x=M.'or x=z'*y' for the answer and when i go to test it i get the error:
assert(isequal(ref_output,student_output));
Assertion failed.
How do I get the correct solution?
1 Kommentar
Nicholas Ayres
am 13 Jun. 2017
You seem to be testing whether the two matrices are exactly the same, including all the values within the matrix. This may be your issue? Also, make sure all your variables are correctly defined. size(<your_variable>) will be the useful function.
Akzeptierte Antwort
Guillaume
am 2 Feb. 2017
The assertion is telling you that your answer differs from the expected answer. That's all.
Now, the reason may be that your answer is indeed wrong. In which case, try harder.
But the reason could also be that you're using a slightly different method to arrive at the result resulting in minute differences in the result due to the way computer stores floating point numbers, in which case you're perfectly entitled to complain loudly to whomever set this test since they don't seem to be aware that you should never use isequal to compare floating point numbers. See for example the result of:
isequal(1.001-0.001, 1)
0 Kommentare
Weitere Antworten (1)
Sally Al Khamees
am 2 Feb. 2017
Bearbeitet: Sally Al Khamees
am 3 Feb. 2017
You cannot view any other answer beside your own on Cody Coursework. It is designed to emulate a homework assignment. You can contact the professor who has created the course to get the solution. Hope this helps
0 Kommentare
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!