I am writing a function to calculate a value of p.
The formula is p=r*q + pa
. The pa
value is column vector which i have got from the ode45
function. I have to change the value of q
w.r.t time i.e from 0 to 1 sec q=500
, from 1 to 2 sec q=0
.
I have written this program:
function [p] = fom(t,pa)
r=0.007;
tin=1;
t=0:0.01:2;
if t <=tin
q = 600;
else t <= 2
q = 0;
end
[t,pa]=ode45('FOM1',[t],[0])
for i=[palv]
p=(r*q)+(i);
end
end
The problem is I am getting correct values after 1 sec in my output but before 1 sec where q is 0 values are not changing. Is this if statement correct?
Aucun commentaire:
Enregistrer un commentaire