How do you add white noise to a nonlinear ODE?

10 views (last 30 days)
I have the following system of differential equations and am trying to add GWN to the input.
f = @(t,y) [alpha * (y(2) + y(1) - (y(1).^3)/3 + ( k1 + c * y(3)+ x));
(-1/alpha) * (w2 * y(1) - a + b * y(2));
alpha * (y(4) + y(3) -( y(3).^3)/3 + (k2 + c * y(1)));
(-1/alpha) * (w2 * y(3) - a + b * y(4)) ];
[T Y] = ode15s(f, [0 1000], [0, 0, 0, 0]);
The input is in bold and the noise is represented by the x. The noise is bandlimited and was created as follows:
% Generate Gaussian White Noise
gwn = wgn(N,1,20);
% create butterworth filter
Wn = 5/(fs/2); %cutoff frequency
[b, a] = butter(4,Wn, 'low'); % get filter coefficients
w = filter(b,a,gwn); % apply filter
However, when I try to add this to my ode, I get the following error:
Error in ==> odearguments at 98 f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode15s at 227 [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ==> Main_ImR at 29 [T Y] = ode15s(f, [0 1000], [0, 0, 0, 0]);
In this case,
a = 0.7; b = 0.8; w2 = 1; alpha = 3; k1 = -1; k2 = -1; c = 0.5;
Why am I getting this error and how would I go about adding the noise to the ode?

Accepted Answer

Torsten
Torsten on 27 Mar 2018
x must be a scalar in your ODE function - I doubt that this is the case.
Best wishes
Torsten.
  3 Comments
Torsten
Torsten on 27 Mar 2018
Define f in a function, not as a function handle. Then you can interpolate x to the time t where it is required by the solver.
Take a look at the paragraph "ODE with time-dependent terms" under
https://de.mathworks.com/help/matlab/ref/ode45.html
for an example.
Best wishes
Torsten.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!