Array indices must be positive integers or logical values.

 采纳的回答

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

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by