Azzera filtri
Azzera filtri

How can I create a for loop?

1 visualizzazione (ultimi 30 giorni)
Sena
Sena il 10 Ott 2022
Commentato: Sena il 10 Ott 2022
Dear all;
I have a question. These are my equations;
a1=1/((1+i/100)^1)
a2=1/((1+i/100)^1)
a50=(((1+i/100)^50)-1)/(i*(1+i/100)^50)
B=(2,5-0,5)*(10^9)*a50*a2
C=20*0,4*(10^9)+(20*0,6*(10^9)*a1)
Max iteration number should be 20. And I need to find the i value that makes B-C=0. Then I need the plot the B and C curves. How can I create a for loop in MATLAB? I try but couldn't succeed.
  2 Commenti
KSSV
KSSV il 10 Ott 2022
In B what does (2,5-0,5) mean?
Sena
Sena il 10 Ott 2022
2,5*10^9 TL is my annual benefit and 0,5*10^9 TL is my operating and maintenance costs so we can basicly say B=2*10^9*a50*a2
Thank you for your answer.

Accedi per commentare.

Risposta accettata

Chunru
Chunru il 10 Ott 2022
n = 20;
B = zeros(n, 1);
C = zeros(n, 1);
for i=1:n
a1=1/((1+i/100)^1);
a2=1/((1+i/100)^1);
a50=(((1+i/100)^50)-1)/(i*(1+i/100)^50);
B(i)=(2.5-0.5)*(10^9)*a50*a2;
C(i)=20*0.4*(10^9)+(20*0.6*(10^9)*a1);
end
plot(1:n, B, 'r', 1:n, C, 'b')

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by