Problem 564. How to subtract?
Solution Stats
Problem Comments
-
7 Comments
Show
4 older comments
Mohamed Atyya
on 30 Oct 2017
good
nipun garg
on 8 Jun 2018
function z = mysub(x,y)
z = num2str( str2num(x) - str2num(y) );
end
why this is not working for this code?
Matt Offredi
on 8 Mar 2019
Nice
Mark Sanderson
on 14 Mar 2019
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
Rafael S.T. Vieira
on 2 Jul 2020
actually each of them has 14 characters or less...15 if we count the signs.
Rafael S.T. Vieira
on 2 Jul 2020
Mark Sanderson, if W > 0 Z = ['+' ...]
Valeriu Mihailov
on 28 May 2022
how about solving this problem but not using any conversion functions like num2str , str2num , str2double ...
Solution Comments
Show commentsProblem Recent Solvers1489
Suggested Problems
-
580 Solvers
-
11278 Solvers
-
Solving Quadratic Equations (Version 1)
470 Solvers
-
634 Solvers
-
788 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!