Symbolic Processing

(Uses Matlab): syms, expand, eval, for loop
Symbolic MATLAB, why bother?

(RLC sample revisited):



Recall the ABCD parameter in Matlab by using the tf LTI objects,

EDU>> R=1; L=1; C=1; %Assume R=L=C=1
EDU>> T1 = [1,R; 0,1];
EDU>> T2 = [1, tf([L,0],1); 0,1];
EDU>> T3 = [1,0; tf([C,0],1),1];
EDU>> TF = T1*T2*T3;
EDU>> V0V1=1 / TF(1,1)

which generate the following result,
Transfer function:
1
---------------
s^2 + s + 1

There is a definite disadvantage of the above procedure. It require, beforehand, knowledge of the constant values for R, L and C. This is unacceptable where a "generic" result is wanted.

Here the Symbolic MATLAB really shine. We tell Matlab our symbolic expressions as follow,

EDU>> syms R L C s
EDU>> T1=[1,R;0,1];
EDU>> T2=[1,s*L;0,1];
EDU>> T3=[1,0;s*C,1];
EDU>> TF=T1*T2*T3;
EDU>> A=TF(1,1);
EDU>> B=TF(1,2);
EDU>> C=TF(2,1);
EDU>> D=TF(2,2);
EDU>> V01=1/A

V01 =
1/(1+(s*L+R)*s*C)


Lets clean this up by using the expand function,

EDU>> h=expand(V01)

h =
1/(1+s^2*C*L+s*C*R)


Notice there is no mention about what values we must use for R, L and C. The transfer function V0 / V1 is in fact given in terms of R, L and C. Now lets try some fix values and ask Matlab to eval uate them.

EDU>> R=1;L=1;C=1;
EDU>> g=eval(h)

g =

1/(1+s^2+s)


Lets try another set of R,L & C,

EDU>> R=1; L=2; C=2;
EDU>> g=eval(h)

g =

1/(1+4*s^2+2*s)


(Lumped-Delay-line sample revisited):

A specific, vL / vS, m-script was shown before as,

rS=50;
rL=10;
L=4;
C=0.14E-3;
SERIES=[1,tf([L/2,0],1); 0,1];
SHUNT=[1,0; tf([C,0],1),1];
LC=SERIES*SHUNT;
TF=[1,rS;0,1]*LC*LC*LC*LC*LC*LC*LC*LC*LC*LC*LC*LC*SERIES*[1,0;1/rL,1];
step(1/TF(1,1),1)


Now for a "generic" script version we use,

syms rS rL L C s
SERIES=[1,tf([L/2,0],1); 0,1];
SHUNT=[1,0; tf([C,0],1),1];
LC=SERIES*SHUNT;
TF=[1,rS; 0,1]*LC*LC*LC*LC*LC*LC*LC*LC*LC*LC*LC*LC*SERIES*[1,0; 1/rL,1];

To see the step response of a Match terminated line we introduce,

rS=50;
rL=50;
L=4;
C=0.14E-3;
step(eval(1/TF(1,1)),1)

(REMARK): This symbolic source code for the delay-line, DO NOT WORK in the student version. Matlab symbolic processing efficiency is disappointingly VERY SLOW and require too much resources.


Let us use For Loop and execute the script for Mountain Bike Suspension for damping constant of b=1 and 2, and merge the two plots into one graph.

The script is,

	%ss2tf3.m
	for b=1:2
		A=[0,1,0; -3,0,2; 2/b,0,-2/b];
		B=[0;1;0];
		C=[1,0,0];
		D=0;
		sys = ss(A,B,C,D);
		step(tf(sys));
		hold ;
	end  

The result,