how can we solve this 2 equation?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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 件のコメント
KALYAN ACHARJYA
2020 年 4 月 12 日
Define all variables, after that just calculate ...
b=.................
n=.................
A=(b+300)+250+100-400;
P=A*(1-(1+50)^-n)/50;
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
2020 年 4 月 12 日
Unless your teacher requires a loop, you don't need one. See Ameer's answer below.
採用された回答
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 件のコメント
Image Analyst
2020 年 4 月 12 日
Can you format the code ONLY as Code, and not the command window stuff. Otherwise they can click Copy but get all the non-runnable stuff also. Then after they paste into a script, they'll have to delete the command window stuff or else get an error.
Ameer Hamza
2020 年 4 月 12 日
Good idea. Thanks for pointing out.
Mamad Mamadi
2020 年 4 月 14 日
Ameer Hamza thank you very much for your great answer realy helped me. but i wanna say the results are different from my calculation in excel am i wrong in calculation?
the results:

and how is it possible to show the results of A1 to A50 like P1 to P50 ?
Ameer Hamza
2020 年 4 月 14 日
編集済み: Ameer Hamza
2020 年 4 月 14 日
Mamad, in your question, the b was not multiplied with 83. If you multiply it, you will get the same answer
n = 20;
b = [1 5:5:50];
A = (83*b+300)+250+100-400;
P = A*(1-(1+50)^-n)/50;
Mamad Mamadi
2020 年 4 月 14 日
ok understood your right thank you bro ☺
Ameer Hamza
2020 年 4 月 14 日
I am glad to be of help.
Mamad Mamadi
2020 年 4 月 18 日
Mr Ameer thanks for your helping, i wanted to mention that the codes you write give the wrong answer again coz i am new at matlab i didnt find the problem. i solved it in excel one by one but the answers are different?!! :( thanks
Ameer Hamza
2020 年 4 月 18 日
Can you post the MATLAB code you are running?
Mamad Mamadi
2020 年 4 月 19 日
i changed the values.

clc; clear all;
Cc= 1311.28
M = 21
R = 514
S = 279
I = 0.05
a=83
n = 20;
b = 1:5:50;
P = zeros(1,numel(b));
for i=1:numel(b)
A(i) = (a*b(i)+Cc+M+R)-S;
P(i) = (A(i)*(1-(1+I)^-n))/I;
end
Ameer Hamza
2020 年 4 月 19 日
I am exactly getting the same values.

Mamad Mamadi
2020 年 4 月 19 日
編集済み: Mamad Mamadi
2020 年 4 月 19 日
yes you are right sir but the problem is here coz when b=5 'A ' must be '1982' and P=24704 and so on.
Ameer Hamza
2020 年 4 月 19 日
But column E of your excel sheet shows when b=5, then A=1650 and P=25737. The column H and I must have a different formula.
Mamad Mamadi
2020 年 4 月 19 日
both of them are the same formula sir.
in matlabs answer, when b=5 then A=2065 and P=25737 give us the wrong answer.
but in excel sheet the answer is, when b=5 then A=1982 and P=24704
Ameer Hamza
2020 年 4 月 19 日
Can you attach your excel file?
Mamad Mamadi
2020 年 4 月 19 日
excel sheet
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 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
