Q:

Either in a script or in the Command Window, create a string variable that stores a string in which numbers are separated by the character ‘x’, for example '12x3x45x2'

0

Either in a script or in the Command Window, create a string variable that stores a string in which numbers are separated by the character ‘x’, for example '12x3x45x2'. Create a vector of the numbers, and then get the sum (e.g., for the example given it would be 62 but the solution should be general).

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

>> str = '12x3x45x2';

>> vec = str2num(strrep(str,'x',' '));

>> sum(vec)

ans =

 62

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now