function simulink2TF(model);
% This function gives a linearized transfer function from a simulink model.
% To run this, you must place "in" and "out" ports within your model, and
% then run the simulation. Afterwards you can do this. See Gene Massion for
% document showing placement of in/out ports.

% Example: simulink2TF('profiling_float_model')
% model - string of simulink block model name
%
% Laughlin Barker
% Summer Intern 201 
% Chem. Sensors Lab

% Create matricies for (linearized) SS model based on block diagram
% gives SYS.a, SYS.b, SYS.c, SYS.d for standard Ax + Bu, Cx + Du SS model
SYS = linmod(model);

TSS = ss(SYS.a,SYS.b,SYS.c,SYS.d);

[num,den] = tfdata(TSS,'v');

disp('Your transfer function is: ')
T = tf(num,den)

poles = pole(T)
zeros = zero(T)

%Now lets plot RL

figure;
rlocus(TSS);

figure;
pzplot(TSS);

figure;
step(TSS);

sisotool(TSS)