Setting a function equal to some value by changing another value.

I am trying to solve my function "morgpay" = to 600 by changing the down payment value (d). My program is working fine but I cannot get it to save my d value for the y of 600. I'm very new to Matlab so I would assume this something simple but I can't figure it out. Thanks!
for d= 250000:349900
if y == 600
d = dg
end
y=morgpay(.2240,15,349900,d);
end

1 件のコメント

Rik
Rik 2020 年 10 月 5 日
I would recommend doing the Onramp tutorial (which is provided for free by Mathworks). That should teach you how to handle changing values in a loop and how to use functions.

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2020 年 10 月 5 日
編集済み: Matt J 2020 年 10 月 5 日

0 投票

If morgpay is monotonic in d, it may be more efficient to use fzero(),
fun=@(d)morgpay(.2240,15,349900,d)-600;
dg=fzero(fun,[250000,349900])

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

質問済み:

2020 年 10 月 5 日

編集済み:

2020 年 10 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by