MATLAB: Array indices must be positive integers or logical values.

exponentsMATLAB

price=25000
dp=1000
r=1.06
rm=r/12
loan=24000
n=[2:1:10];
payment=loan*((rm(1+rm)^n)/(((1+rm)^n)-1))

Best 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’.