Output response from closed loop transfer function using MATLAB

401 Views Asked by At

This transfer function is to control the position of Permanent Magnet DC motor. I was able to get the transfer function and now I need to analyze the output for the tuned closed loop for a given input function. Closed Loop Transfer Function

To solve this problem, my solution was cross multiply the equation and take the inverse Laplace transformation and after solve it as a differential equation. So I've written a MATLAB code and that MATLAB code gives me an error message. Can anyone help me to identify my error in the code or the way I've chosen to solve this problem?

MATLAB Code

t = 0:0.0001:1/180;
kp = 10;
kd = 1.3;
eqn ='0.00072*D3x+0.07206*D2x+(0.7274*kd+0.44244)*Dx+0.7274*kp*x=(0.7274*kd*Dt+0.7274*kp*t)*60*t';
inits = 'x(0)=0,Dx(0)=60,D2x(0)=0,t(0)=0';
x = dsolve(eqn,inits,'t');
z = eval(vectorize(x));
plot(t,z),grid on
1

There are 1 best solutions below

4
On BEST ANSWER

You are not using the capabilities of MATLAB correctly.

I will give an example. You can define the transfer function (from MATLAB documentation)

$$G(s) = \dfrac{8s^2+2s+32}{3s^3+6s^2+14s+24}$$

by the following line in MATLAB

sys = tf([8 2 32],[3 6 14 24]).

Then you can get the system responses by

subplot(2,1,1)
step(sys)    % step response
subplot(2,1,2)
impulse(sys) % impulse response

or use an arbitrary time input (e.g. $\sin(10 t)$)

t = 0:0.01:4;
u = sin(10*t);
lsim(sys,u,t)   % u,t define the input signal

EDIT: Constructing piecewise defined functions. In order to define the piecewise function

$$f(t) = \begin{cases} f_1(t)&\quad \text{, for } t \leq t_1 \\ f_2(t)&\quad \text{, for } t_1 < t \leq t_2\\ f_3(t)&\quad \text{, for } t_2 < t \leq t_3\\ f_4(t) &\quad \text{, for } t_3 < t \end{cases}$$

we can use the Heaviside step function. In your case $f_4(t)=0$. You can construct your input as

u = f_1(t) + [f_2(t) - f_1(t)] * heaviside(t-t_1) + [f_3(t) - f_2(t)] * heaviside(t - t_2) + [f_4(t) - f_3(t)] * heaviside(t - t_3)