What is the way of solving the noise added differential equations in matlab?
20 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
採用された回答
Alan Stevens
2022 年 2 月 9 日
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 件のコメント
Bruno Luong
2023 年 9 月 2 日
編集済み: Bruno Luong
2023 年 9 月 2 日
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
2025 年 7 月 16 日
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.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!