Using ss2tf when your matrices are variables without values yet

syms m b k
A = [0 (1/m+1/b);-k (-k/m-k/b)]
B = [0;k]
C = [0 1]
D = [0]
[b,a] = ss2tf(A,B,C,D)
I would like to get the transfer function of those matrices but the ss2tf function requires the matrices to be numerical. Is there a way to get a symbolic answer or am I looking at the wrong function?

2 Comments

To be explicit:
ss2tf() does not work on symbolic variables. Very few of the functions in the Control System Toolbox will work with symbolic variables (the ones that do work are more or less by accident.)
ss2tf is not listed on the Control System Toolbox Functions page nor (very surprisingly to me) on the Signal Processing Toolbox Functions page. It's been out of vogue from the CST for so long that I'm always a bit surprised when I see it brought up and wonder why users are asking about it. Not sure when it was taken of the SPT doc; maybe that's been more recent and the reason users still try to use it.
FWIW, tf2ss is still a documented function in the SPT, and it does happen to work with symbolic inputs.

Sign in to comment.

 Accepted Answer

I would not use the Symbolic Math Toolbox for this!
For undefined variables, use anonymous functions for them, and then pass the arguments to them later —
A = @(b,k,m) [0 (1/m+1/b);-k (-k/m-k/b)]
A = function_handle with value:
@(b,k,m)[0,(1/m+1/b);-k,(-k/m-k/b)]
B = @(k) [0;k]
B = function_handle with value:
@(k)[0;k]
C = [0 1]
C = 1x2
0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
D = [0]
D = 0
[n,d] = ss2tf(A(1,2,3),B(2),C,D)
n = 1x3
0 2 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
d = 1x3
1.0000 2.6667 2.6667
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
EDIT — (10 Aug 2024 at 13:55)
Also —
A = @(b,k,m) [0 (1/m+1/b);-k (-k/m-k/b)]
A = function_handle with value:
@(b,k,m)[0,(1/m+1/b);-k,(-k/m-k/b)]
B = @(k) [0;k]
B = function_handle with value:
@(k)[0;k]
C = [0 1]
C = 1x2
0 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
D = [0]
D = 0
TFfcn = @(b,k,m) ss2tf(A(b,k,m),B(k),C,D);
b = 1;
k = 2;
m = 3;
[n,d] = TFfcn(b,k,m)
n = 1x3
0 2 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
d = 1x3
1.0000 2.6667 2.6667
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
.

More Answers (1)

Hi Wynand,
For a low-order problem like this, you can use the Symbolic toolbox to evaluate the equtation that computes the transfer function from the state space matrices. If you try it without success, feel free to post back here showing the code you tried and what the problem is.
Also, assuming this model represents some sort of mass-spring-damper system, I suggest reviewing the derivation of the state space matrices, because the A and B matrices don't look correct. For example, 1/b does not have the same units as 1/m.
syms m b k
A = [0 (1/m+1/b);-k (-k/m-k/b)]
A = 
B = [0;k]
B = 
C = [0 1];
D = [0];
%[b,a] = ss2tf(A,B,C,D)

8 Comments

As a hint, the formula to derive the transfer function matrix from the linear state-space model is given by:
The size of the transfer function matrix should be the same as matrix , which is obvious in the equation above.
Note: Edited to correct the formula. Thanks Paul.
Hi Sam,
Please check that response ....
Thanks @Paul, I appreciate you pointing that out. The chosen symbols m, b, k and the 2nd-order system structure may lead readers to believe the model is analogous to a mass-damper-spring mechanical system. I hope @Wynand could explain how the state-space model was derived from the fundamental principles of physics before using the state-space-to-transfer-function formula.
Hi Sam,
I meant for you to check your response. Looks like that equation for G(s) was typed too quickly.
Good day @Sam Chak and @Paul
I added an image of the system in question and the consitutive equations I came to. I am not 100% sure about the matrix and would not be suprised if I made an error somewhere.
I assumed 2 distinct velocities because the cable has a spring constant to it.
I used:
Y2' = (1/M)(F_m)
F_k' = k(Y1'-Y2')
F_b = bY2'
with ' indicating derivatives
I am redoing the state space model now and will update this with the new results
The differential equation should look like this:
.
Convert it to the state-space model.
Good day @Sam Chak
I redid my work and go to this transfer function
syms k m b s
T = k/(m*s^2+b*s+k)
T = 
This seems to be inline with the equation you have as well. Thank you for you engagement
Please note that your transfer function does not include the gravity term 'mg'. Either you did not account for the effect of gravity, or you canceled out the effect of gravity in the force term , as follows:
which results in
.
If the latter is the case, then the transfer function is valid:
.
Your next step is to design a stabilizing equation such that the elevator reaches the target floor at the desired settling time without overshoot. Note that if you use the popular unconstrained Proportional–Derivative equation, the elevator will reach all target floors at the same settling time. For high-rise buildings, this assumption is somewhat unrealistic.
Additionally, please consider researching Otis Elevator, Kone Elevator, Toshiba Elevator, and Schindler's Lifts if possible.

Sign in to comment.

Asked:

on 10 Aug 2024

Commented:

on 15 Aug 2024

Community Treasure Hunt

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

Start Hunting!