0
$\begingroup$

I have the coefficients of a transfer function (i.e. numerator and denominator) in Laplace domain. How can I apply this to an input waveform using MATLAB script? I am looking for a function or piece of code that does the same job as 'Transfer Fcn' block in Simulink.

I know the 'filter(num, den, input)' command in MATLAB does not work in my case as this function only accepts discrete domain coefficients. I also want to avoid the c2d() command that converts the continuous system to discrete.

So basically I am looking for a direct solution in the continuous domain without using the simulink block.

Any help is greatly appreciated.

$\endgroup$
0
$\begingroup$

One approach could be to get a finite number of values of the impulse response of your system using the 'impulse' function, and then convolve this with your signal (taking care of the actual sampling frequency you are using).

% sampling time of 1ms, 20s of time signal 
T = 0.001;
t = 0:T:20;

% low pass filter with cutoff frequency at sine frequency
wo = 1;
x = sin(wo*t);
s = tf('s');
H = wo / (s+wo);

% get the h(t)
h = impulse(H,t);

% plot the output
plot(t,x);
y = T*conv(x,h);
y = y(1:length(x));
hold all;
plot(t,y)

enter image description here

$\endgroup$
0
$\begingroup$

You can use the lsim command, it works for discrete and continuous systems.

https://www.mathworks.com/help/control/ref/lsim.html

In your case, the 'sys' variable should replaced by tf(num,den)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.