Taking a descend interval

조회 수: 1 (최근 30일)
Jane Smith
Jane Smith 2021년 3월 5일
댓글: Jane Smith 2021년 3월 5일
for t=1:n
[L(t)]=(1/(50)^(t))
[C(t)]=(1/(800))^(t);
end
For the 1st line (L(t)) i need to use the interval 1:n however for the 2nd line i need from n:1. How do i change t without changing the interval in the for loop?

채택된 답변

Alan Stevens
Alan Stevens 2021년 3월 5일
Insert
tau = n+1-t;
then raise 1/800 to the power tau.
  댓글 수: 1
Jane Smith
Jane Smith 2021년 3월 5일
Worked perfectly! Thanks

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by