how can we solve this 2 equation?

1 回表示 (過去 30 日間)
Mamad Mamadi
Mamad Mamadi 2020 年 4 月 12 日
コメント済み: Ameer Hamza 2020 年 4 月 19 日
hi dear friends could you plz do me a favor and solve these two equations? the equations are for finding PV cost analysis.
i have two equations
b=53
n=20
1- A=(b+300)+250+100-400
2- P=(A*(1-(1+50)^-n)/50
b is variable b=1:5:50
the system is works for n=20 years. For every b variable i have to find P ;
thanks ;)
  3 件のコメント
Mamad Mamadi
Mamad Mamadi 2020 年 4 月 12 日
we have to use for loop i think coz b is variable i mean put 5xb to find p1 and put 10xb to find p2 and so on till 50xb
Image Analyst
Image Analyst 2020 年 4 月 12 日
Unless your teacher requires a loop, you don't need one. See Ameer's answer below.

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 12 日
編集済み: Ameer Hamza 2020 年 4 月 12 日
Both of the following codes are equivalent.
Vectorized:
n = 20;
b = 1:5:50;
A = (b+300)+250+100-400;
P = A*(1-(1+50)^-n)/50;
Result:
P =
Columns 1 through 7
5.0200 5.1200 5.2200 5.3200 5.4200 5.5200 5.6200
Columns 8 through 10
5.7200 5.8200 5.9200
For-loop
n = 20;
b = 1:5:50;
P = zeros(1,numel(b));
for i=1:numel(b)
A = (b(i)+300)+250+100-400;
P(i) = A*(1-(1+50)^-n)/50;
end
Result:
P =
Columns 1 through 7
5.0200 5.1200 5.2200 5.3200 5.4200 5.5200 5.6200
Columns 8 through 10
5.7200 5.8200 5.9200
  16 件のコメント
Mamad Mamadi
Mamad Mamadi 2020 年 4 月 19 日
excel sheet
Ameer Hamza
Ameer Hamza 2020 年 4 月 19 日
Mamad, In this comment: https://www.mathworks.com/matlabcentral/answers/517357-how-can-we-solve-this-2-equation#comment_827851 I also modified the value of 'b'. But you didn't changed it in your code. Closely see the difference between the value of 'b', I wrote in that comment and your code, and you will find the mistake.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by