Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Dharma
Dharma le 10 Avr 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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)

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by