So I'm trying to get user input but when I run the code, I get the error "Index exceeds the number of array elements (1)." I looked up how to use the input function and it looks correct so I'm not sure why this error is coming up. I'm on macOS if that's relevent at all.
prompt = 'Amount to add: ';var = input(prompt);mysum(var);function sum = mysum(var) sum = 0; for i = 1:var sum = sum + i; endend
Best Answer