Repeated application of lsim()
Afficher commentaires plus anciens
Hello,
I am using lsim to calculate the response to an input noise signal in a column vector. My model is a simple first-order continuous time SISO filter. This works fine for a single trial of the input.
Now I want to repeat this for say 100 random trials. I usually do this by creating a matrix for my input signal with each column representing a trial. But this does not seem to work with lsim().
Here is the basic code that works for Ntrials=1.
num = 1; den = [1 1]; sys = tf(num, den);
dt = 0.1; t = (0:dt:10).';
Ni = length(t); % Number of time samples
Ntrials = 1; % Number of trials.
x = randn(Ni, Ntrials); % input signal y = lsim(sys, x, t); % output signal
plot(t,y)
In general is there a simple way to vectorize a simulation like this? Say I do everything with column vectors as above and then when I want to switch to looking at repeated trials. Is there a way to get matlab to just go off and adds columns for each trial (without me rewriting a lot of code)?
Thanks
Réponses (0)
Catégories
En savoir plus sur Control System Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!