uppLim = length(value) - 1;
Should solve your problem. Oh and drop the
which is basically an endless loop because value doesn't change inside the loop. it's also not necessary because the
doesn't enter the loop when value is empty.
I would also ditch the for loop, and vectorize it
list = input('Enter a list of positive intergers separated by commas:', 's');
value = strsplit(list, ','); value = str2double(value);
x = sum(value([false diff(value) > 0]));
disp(['The sum of the numbers = : ' num2str(x)]);
Best Answer