필터 지우기
필터 지우기

How can I create a for loop?

조회 수: 1 (최근 30일)
Sena
Sena 2022년 10월 10일
댓글: Sena 2022년 10월 10일
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
KSSV
KSSV 2022년 10월 10일
In B what does (2,5-0,5) mean?
Sena
Sena 2022년 10월 10일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Chunru
Chunru 2022년 10월 10일
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')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by