# Electronic – 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.

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.