# Comparing Responses for Linear and Non-Linear System in Simulink

I am going through and reviewing this unprofessional (I highlight a potential mistake in Section3.4) paper: Nonlinear Model & Controller Design for Magnetic Levitation System

Specifically, I am trying to compare the responses of the linear and non-linear model in Simulink, using the parameters provided in Table 1 of that same paper. I am to comment on any discrepancies.

I am having trouble comparing responses, since they are totally different from each other.I suspect that I may have a mistake/misunderstanding when it comes to plotting the non-linear model. A very brief summary of the paper follows.

System Non-Linear Vector Format Linear Model Comparing Responses - Working

For the non-linear model I used a MATLAB function block, with the following script:

function y = fcn(u)

g = 9.81;
m = 0.05;
R = 1;
L = 0.01;
C = 0.0001;
x1 = 0.012;
x2 = 0;
x3 = 0.84;

% nonlinear set of equations
x = [x2; g-((C/m)*(x3/x1)^2); -((R/L)*x3 + (((2*C)/L)*(((x2*x3)/((x1)^2)))))] + [0;0;1/L]*u;

y = x';


I then gave a step input to the system and got the following result. Yellow is the step input, green is the output. Next, I proceeded with the linear model. I placed the matrices A, B, C and D inside a state space block. To get the numbers you see above, I replaced the constants with the parameters given in the paper. I got the following output. As can be seen, both responses are completely different, and I am unsure about what discrepancies I should comment about. Are my non-linear and linear model implementations correct? I can add further details or workings if required. Parameters: Any help would be appreciated.

• Re-calculate the bottom line of your $A$ matrix. – TimWescott Nov 16 '18 at 21:33
• I am getting: [0 116.66 -100] – rrz0 Nov 16 '18 at 21:45
• Value seems correct... – rrz0 Nov 16 '18 at 22:08
• A quick scan of your results tells me that (1) the non-linear model does't seem to be representing any dynamics, and (2) the linear model is not converging. Have you checked the eigenvalues of your linear state matrix? – Edgar Brown Nov 16 '18 at 22:08
• I meant, recalculate the bottom line of your symbolic representation of your $A$ matrix. It is in error. (I'm assuming this is homework, or answers would be spewing forth). – TimWescott Nov 16 '18 at 22:49

Ah HA!. You used a Matlab nonlinear function block, but you're misunderstanding the system equation. The function $$\\dot{\vec x} = f(\vec x, u)\$$ is coughing up the derivative of $$\\vec x\$$, not $$\\vec x\$$ itself. You need to have a function block that just finds $$\\dot{\vec x}\$$ from $$\\vec x\$$ and $$\u\$$, then feeds it to an integrator (Simulink should be able to integrate a vector just fine) and feeds the $$\\vec x\$$ back to the block, and extracts $$\y\$$ from it. • Because the vector on the left side is $[ \dot x_1 \dot x_2 \dot x_3 ]^T$, not $[ x_1 x_2 x_3 ]^T$. A dot over a variable denotes its time derivative. – TimWescott Nov 17 '18 at 18:00