Problem 49062. Mass Conversion 2
Solution Stats
Problem Comments
-
10 Comments
Test criteria is wrong, can't assert the right return value.
The description has been updated to state the precision of the conversion factor used in the test suite.
some error , as in scratch pad it is working but while submitting it shows error
Problem statement needs to be updated to state precision of submitted values. Only accepts values rounded to 4-decimal places.
Answers need to be rounded to 4 decimal places
If you're facing the issue where your code is producing correct results, but the assertion tests fail, use the round() function and set the precision to 4 decimal places.
% my solution - print out y value to compare against y_correct
y = x / 2.205;
disp(['y = ' num2str(y)])
disp(y)
% Test 2 and 3 Fail....
x = 50;
y_correct = 22.6757;
assert(isequal(convert_stuff(x),y_correct)) % Assertion failed.
Output:
y = 22.6757 % NOT SURE WHY THIS FAILS????
22.6757
%% Does not look like a precision issue
Big +1 to all the comments saying that the answers need to be rounded to 4 decimal places. Please put this in the description
hint: round to the 4th decimal
Hint:
The code will only be solved if you use rounding to FOUR decimal places.
To do this use the command:
y = round(("equation"),4)
Solution Comments
Show commentsProblem Recent Solvers965
Suggested Problems
-
Replace NaNs with the number that appears to its left in the row.
3059 Solvers
-
Project Euler: Problem 9, Pythagorean numbers
1432 Solvers
-
Return the first and last characters of a character array
11740 Solvers
-
Side of an equilateral triangle
6852 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
2132 Solvers
More from this Author180
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!