Array indices must be positive integers or logical values.

 Accepted Answer

Add some multiplication and element-wise operators:
payment=loan*((rm*(1+rm).^n)./(((1+rm).^n)-1));
↑ ↑ ↑ ↑ ← AS INDICATED BY THE ARROWS
and your code works.
The error had to do with:
rm(1+rm)
since MATLAB interpreted ‘(1+rm)’ as a subscript reference to ‘rm’.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!