Problem 564. How to subtract?
function z = mysub(x,y)
z = num2str( str2num(x) - str2num(y) );
why this is not working for this code?
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 = ['+' ...]
how about solving this problem but not using any conversion functions like num2str , str2num , str2double ...
Solution CommentsShow comments
Problem Recent Solvers1489
Back to basics 11 - Max Integer
Getting the indices from a vector
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
A Simple Tide Gauge with MATLAB
More from this Author100
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!