What is the way of solving the noise added differential equations in matlab?

20 visualizaciones (últimos 30 días)
I want to study the stoichastic resonance in duffing oscillator. The duffing oscillator is given as,
,
where are constant parameter and f is the forcing amplitude and is the white gaussian noise and D is the varience. I want to see the effect of noise on the dyanmics of the system. I tried solving the above equation using ode45 but it's not giving any results......
clear all;
clc;
clf;
%% ----------------INPUT PARAMETERS---------------------------
=0.33; alpha=0.5; w0=sqrt(-1); beta=1; w=0.96; D=10;
x0 = [-1 0 0]; %initial condition
tspan = [0:0.1:100]; %time duration
n_rec= 300; %recording time
options = odeset ('RelTol',1e-7,'AbsTol',1e-6); %acuuracy set
[t,x] = ode45('duffing_sr',tspan,x0, options); %solving using ode45
[row, col]=size(x);
%Storing the data after discarding initial transients
x1 = x(n_rec:row,1);
x2 = x(n_rec:row,2);
x3 = x(n_rec:row,3);
n = length(x1); % Length of x1 after discarding the initial transients
t_n=t(n_rec:row);
plot(t_n,x1); %plotting
%---------------------------Function-----------------------------------------------
function dxdt = duffing_sr(t,x)
global f alpha w0 beta w D ;
dxdt = zeros(3,1);
dxdt(1) = x(2);
dxdt(2) = f*sin(x(3))-alpha*x(2)-w0^2*x(1)-beta*x(1)^3+sqrt(D)*(randn()-0.5);
dxdt(3) = w;
end
****************************************************************************************
I have no idea how to solve noise added differential equations.

Respuesta aceptada

Alan Stevens
Alan Stevens el 9 de Feb. de 2022
Try to avoid the (mis)use of global!
%% ----------------INPUT PARAMETERS---------------------------
f=0.33; alpha=0.5; w0=sqrt(-1); beta=1; w=0.96; D=10;
x0 = [-1 0]; %initial condition
tspan = 0:0.1:100; %time duration
n_rec= 300; %recording time
%options = odeset ('RelTol',1e-7,'AbsTol',1e-6); %acuuracy set
[t,x] = ode45(@(t,x) duffing_sr(t,x,f,alpha,beta,w,D),tspan,x0); %solving using ode45
[row, col]=size(x);
%Storing the data after discarding initial transients
x1 = x(n_rec:row,1);
x2 = x(n_rec:row,2);
n = length(x1); % Length of x1 after discarding the initial transients
t_n=t(n_rec:row);
plot(t_n,x1); %plotting
%---------------------------Function---------------------------------------
function dxdt = duffing_sr(t,x,f,alpha,beta,w,D)
dxdt = [x(2);
f*sin(w*t)-alpha*x(2)-(-1)*x(1)-beta*x(1)^3+sqrt(D)*(randn-0.5)];
end
  22 comentarios
Bruno Luong
Bruno Luong el 2 de Sept. de 2023
Editada: Bruno Luong el 2 de Sept. de 2023
The most known is Kolmogorov's K41 theory. I do not follow the latest development, but you can start with such paper on simple Burgers 1D model https://hal.science/hal-03110850/document
Jürgen
Jürgen el 16 de Jul. de 2025
The noise injection in the example is directly added in the ODE function for the Duffing oscillator. I don't feel comfortable with that in the case of an adaptive step solver like ode45. The randn function is activated at every call of the ODE function, which, if I am correct, happens four times per valid time step for ode45. My intuition is that this likely reduces the noise compared to the intended sqrt(D) value. I believe it should only be activated once: when the ode45 solver chooses the total step. However, this means one must modify the ode45 code. I considered using 'OutputFcn' to trigger the random generation, but this also does not work, as the valid duration of the step is only known after the step. The correct computation of the noise injection requires knowledge in advance to compute the magnitude of the random inhomogeneity injection, which must be derived from its spectral density.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by