Problem 564. How to subtract?
Solution Stats
Problem Comments
-
6 Comments
good
function z = mysub(x,y)
z = num2str( str2num(x) - str2num(y) );
end
why this is not working for this code?
Nice
Hi. My code only prints out '-' for a negative number but not '+' for a positive. Can anyone help? function Z = mysub(X,Y); W = (str2num(X))-(str2num(Y)); Z = num2str(W); end
actually each of them has 14 characters or less...15 if we count the signs.
Mark Sanderson, if W > 0 Z = ['+' ...]
Solution Comments
-
1 Comment
piece of cake
-
1 Comment
+-=
-
1 Comment
string to double and sprintf
-
1 Comment
Need to calculate the difference ... not the sum! :)
-
1 Comment
Sorry for this...just had to try regexp. Somehow, the size of this is calculated completly wrong.....
Problem Recent Solvers1471
Suggested Problems
-
Project Euler: Problem 7, Nth prime
1009 Solvers
-
241 Solvers
-
Magic is simple (for beginners)
5236 Solvers
-
1101 Solvers
-
Van Eck's Sequence's nth member
305 Solvers
More from this Author100
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!