linearize a second-order system without symbolic math toolbox in matlab

To linearize a second-order system using state-space representation in MATLAB, you can use the following steps:

  1. Define the state-space system for the second-order system:
main.m
% Define the parameters of the system
m = 1.5; % Mass
k = 2;   % Spring constant
c = 0.5; % Damping coefficient

% Define the state-space system
A = [0 1; -k/m -c/m];
B = [0; 1/m];
C = [1 0];
D = 0;

sys = ss(A,B,C,D);
219 chars
13 lines
  1. Use the linearize function to linearize the system at a specific operating point. The operating point is defined as a vector of input and output values for the system. For example, if you want to linearize the system when the input is 0 and the output is 1, you can use:
main.m
op = [0; 1];  % Define the operating point
sys_lin = linearize(sys,op);
72 chars
3 lines

This will give you the linearized state-space system at the operating point.

Alternatively, you can use the ss function to create a linearized state-space system directly. The ss function takes the original state-space system and the operating point as input arguments:

main.m
sys_lin = ss(A,B,C,D,'InputStateName',{'u'},'OutputName',{'y'});
x_op=[0; 0];y_op=1;u_op=0;
sys_lin=ss(A-B*K,[B N],C,[],'inputname','[r;n]','outputname','[yhat;dhat]');  
[syse,G,Ti,To]=interconnect(sys,K,sys_lin,1,2,[],[]) 
225 chars
5 lines
  1. You can then use the step function to simulate and plot the response of the linearized system:
main.m
t = 0:0.1:10;  % Define the simulation time
u = zeros(size(t));  % Define the input signal
[y,t,x] = step(sys_lin,t,u);  % Simulate the response
plot(t,y);  % Plot the output response
184 chars
5 lines

This will give you a plot of the step response of the linearized system.

gistlibby LogSnag