필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

If y(j) is less than some number (say 3) then I want to use higher value of k (say 4) but in the range of 5th iteration before and after y becomes 3. For example in 40th iteration y becomes 3. I want to use k=7 from 35th to 45th iteration. Pls help.

조회 수: 1 (최근 30일)
N=100;
dt=0.05;
k=2;
t=zeros(N,1);
y=zeros(N,1);
y(1)=2;t(1)=0;
for j=1:N-1
t(j+1)=t(j)+dt;
y(j+1)=y(j)+dt*(2+k);
end
plot(t,y)
  댓글 수: 2
John D'Errico
John D'Errico 2018년 3월 26일
편집: John D'Errico 2018년 3월 26일
Your question is quite confusing, because the criteria seems to be depend on several things that are not really clear.
Regardless, what stops you from using an if statement to choose k, based on the value of y(j), or iteration, etc?
Dharma
Dharma 2018년 3월 26일
Thank you John,
My actual code involves sine function. If I impose if condition on y and then use higher value of k ( if y (j) <3 k=4) then many spikes ( means k=4 is taken frequently like spikes) in k vs t plots will be seen. So I am trying to give k=4 for some finite interval of time. But that time interval should be the one in which y goes beyond 3.

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by