Adding random noise in different timestep while numerical integration

1 visualizzazione (ultimi 30 giorni)
How can I add a "random factor" only in every second integration step?
Because maybe I don't want to add the Random all the time - for example I Want to add it in time steps = 0.004 or maybe 0.008.
dt = 0.002;
end_1 = 2.0;
time = 0:dt:end_1;
Matrix = zeros(10,length(time);
Matrix(:,0.5/dt:0.6/dt) = repmat(...);
Random = randn(10,length(time);
Matrix = Matrix + Random;
what is the best way to add Random in a different tilmestep than dt?
This dt = 0.002 will later serve as an integration step for solving a differential equation where matrix occurs - now, however, I would like to add the random component in, for example, coarser time steps (every 2nd ... or possibly only every 10th step).

Risposte (1)

Dongyue
Dongyue il 18 Nov 2022
Hi Thomas,
You can use mod() function as a flag, to trigger the adding ramdom process.
if mod(time, 0.04)==0
Matrix = Matrix + Random;
end
For detailed information of mod() function, please go through the link below:
Best,
Dongyue

Categorie

Scopri di più su Linear Algebra in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by