I want to multiply the first two numbers of a digit together and subtract the third from it!
3 views (last 30 days)
Show older comments
I have the number
223456
I want to multiply the first two digits together and subract by the third. example from above: 2*2-3
I have made the number into a string using the following:
%convert the number to individual digits digits = code_string - '0';
so as far as I know the matrix looks like: [2 2 3 4 5 6] and again I want to multiply the first number by the second and subtract the third.
Thanks!
Lucky
0 Comments
Accepted Answer
per isakson
on 9 Feb 2015
Another way (, which I like better)
str = '223456';
cac = textscan( str, '%1f%1f%1f%*s', 'CollectOutput', true );
num = cac{1}
num(1)*num(2)-num(3)
returns
num =
2 2 3
ans =
1
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!