Borrar filtros
Borrar filtros

How can I create a for loop?

1 visualización (últimos 30 días)
Sena
Sena el 10 de Oct. de 2022
Comentada: Sena el 10 de Oct. de 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 comentarios
KSSV
KSSV el 10 de Oct. de 2022
In B what does (2,5-0,5) mean?
Sena
Sena el 10 de Oct. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Chunru
Chunru el 10 de Oct. de 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')

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by