Adding random noise in different timestep while numerical integration
3 ビュー (過去 30 日間)
古いコメントを表示
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).
0 件のコメント
回答 (1 件)
Dongyue
2022 年 11 月 18 日
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!