Clear Filters
Clear Filters

How can I create a for loop?

1 view (last 30 days)
Sena
Sena on 10 Oct 2022
Commented: Sena on 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 Comments
KSSV
KSSV on 10 Oct 2022
In B what does (2,5-0,5) mean?
Sena
Sena on 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.

Sign in to comment.

Accepted Answer

Chunru
Chunru on 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')

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!