From: Duvinage MAtthieu on 18 Mar 2010 07:06 Hi, I would like to integrate a ODE system. However, although the script below works well when I use a function sin(wt), I don't know how to use an external function which is the result of an experiment. How can we handle with this problem ? %principal script Here input signal is only an example but I want to replace this function by a result of an experiment. Fe=1000; %frequence d'échantillonnage time=500; %nombre de secondes tspan=0:1/Fe:time; p=[8; 1; 3]; x0=[1; 0; 5]; input_signal=sin(10*tspan); [t,x]=ode45('adaptative_frequency_oscillators',tspan,x0,[],p,input_signal,Fe); figure plot(t,x(:,1)) figure plot(t,x(:,2)) figure plot(t,x(:,3)) %equation function xprime = aptative_frequency_oscillators(t,x,flag,p,input_signal2,Fe); gamma=p(1); mu=p(2); e=p(3); xprime = zeros(3,1); xprime(1)=gamma*(mu-(x(1)^2+x(2)^2))*x(1) -x(3)*x(2) +e*input_signal; xprime(2)=gamma*(mu-(x(1)^2+x(2)^2))*x(2)+x(3)*x(1); xprime(3)=-e*sin(10*t)*x(2)/sqrt(x(1)^2+x(2)^2); Thank you in advance. Matthieu
|
Pages: 1 Prev: Implementation of FFT and IFFT in Matlab Next: Create a randomized vector with ones and zeros |