Info

This question is closed. Reopen it to edit or answer.

Applying higher value of input parameter for some interval input variable in ODE.

1 view (last 30 days)
N=10;
k=zeros(N,1);
r=zeros(N,1);
t=zeros(N,1);
k1=1;k(1)=1;t(1)=0;dt=0.05;
for i=2:N
t(i)=t(i-1)+dt;
k(i)=k1;
r(i)=r(i-1)*dt+k(i);
if r(i)<5
% I want to apply higher value of k i.e. k1+1 for some
% interval of time before and after t(i) at which r(i) is equal to 0.5.
% For example if t(i)=10 for r(i)=0.5, then
% I want to use higher value of k in the time range of 5 to 15.
k(i)=k1+1;
r(i)=r(i-1)*dt+k(i);
end
end
plot(t,r)

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!