i probaly dont understand how the str2num command wroks but sor some reason when i input 1x1x1, get matlab to remove the x's from it and convert whats left to a serires of numbers and than take the sum of those numbers i get 387. why is that? i know matlab reads a string 1 as 49 thats probably why im getting that answer. How would i get aorund it and get Matlab to read string 1 as the value 1? Thanks for the help.
numbers = input('Enter your numbers that you want the sum of serperated by x: ', 's')erase(numbers, 'x')str2num(numbers)sum1 = sum(numbers,'all')fprintf('the sum of your numbers is = %f', sum1)
Best Answer