Filter löschen
Filter löschen

How to simulate controller and plant without using simulink

14 Ansichten (letzte 30 Tage)
Windell
Windell am 4 Aug. 2017
Beantwortet: Robert U am 11 Aug. 2017
Hello, I have a transfer function and a controller that I would like to simulate using purely matlab. I know that I can use the step() function to simulate the step response, but I would like to generate my own trajectory and input it into my system and not use an integrator such as ode45(). In simulink I can just output the output of my system and the trajectory is plotted. How would I do the same thing in MATLAB code?
The main reason I would like to do this is that I want to feed the output of my system to modify the trajectory at the input, but at a much slower rate than the sample rate of the controller. Im finding it difficult to figuring out how to do this in simulink.

Antworten (1)

Robert U
Robert U am 11 Aug. 2017
Hi Windell:
You can simulate the time response of dynamic systems to arbitrary inputs with lsim ( https://de.mathworks.com/help/control/ref/lsim.html?s_tid=srchtitle ).
Example for a second order lowpass filter:
%%create input signal
fs = 50e3;
time = 0:1/fs:0.2;
signal = chirp(time,100,0.2,1000,'li');
%%create system
system = tf(1,[1/(2*pi*250)^2 2/(2*pi*250) 1]);
%%simulation
[outSignal, time] = lsim(system,signal,time);
%%plot result
plot(time,[signal; outSignal'])
Kind regards,
Robert

Kategorien

Mehr zu General Applications finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by