필터 지우기
필터 지우기

Problem in using the "While" loop function

조회 수: 1 (최근 30일)
Amr Sadek
Amr Sadek 2014년 9월 18일
편집: Yona 2014년 9월 22일
Hello, I have a function, say x=x(t) where x(t=0)=xo and x(t=1)=x(t=0)-fun(t), and x(t=2)=x(t=1)-fun(t), and so on. I want to make a loop function to calculate x(t) till x(t)=0. How can I do that?
Thank you.
  댓글 수: 4
Rick Rosson
Rick Rosson 2014년 9월 22일
  • Is the time domain continuous or discrete?
  • If discrete, what is the time increment?
Amr Sadek
Amr Sadek 2014년 9월 22일
The time domain is discrete with increment 1.

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

채택된 답변

Yona
Yona 2014년 9월 22일
편집: Yona 2014년 9월 22일
you need to define all variables.
n(1)=n0;
while 1
if n(end) <=0
break;
end
n(end+1)=n(end)-S*exp(-E/(k*t));
end
matlab don't like that the length of n change, so you get a warning but it will run. after this, you will have in n all data from t=0 until t: n(t)<=0.

추가 답변 (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