Effacer les filtres
Effacer les filtres

How can I create a for loop?

1 vue (au cours des 30 derniers jours)
Sena
Sena le 10 Oct 2022
Commenté : Sena le 10 Oct 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 commentaires
KSSV
KSSV le 10 Oct 2022
In B what does (2,5-0,5) mean?
Sena
Sena le 10 Oct 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.

Connectez-vous pour commenter.

Réponse acceptée

Chunru
Chunru le 10 Oct 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')

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by