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.


enter image description here

Non-Linear Vector Format

enter image description here

Linear Model

enter image description here

Comparing Responses - Working

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

function y = fcn(u)

    % define your constants
    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.

enter image description here

Next, I proceeded with the linear model. I placed the matrices A, B, C and D inside a state space block.

enter image description here

To get the numbers you see above, I replaced the constants with the parameters given in the paper. I got the following output.

![enter image description here

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.

Simulink build

enter image description here


enter image description here

Any help would be appreciated.

  • \$\begingroup\$ Re-calculate the bottom line of your \$A\$ matrix. \$\endgroup\$ – TimWescott Nov 16 '18 at 21:33
  • 1
    \$\begingroup\$ I am getting: [0 116.66 -100] \$\endgroup\$ – rrz0 Nov 16 '18 at 21:45
  • \$\begingroup\$ Value seems correct... \$\endgroup\$ – rrz0 Nov 16 '18 at 22:08
  • \$\begingroup\$ 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? \$\endgroup\$ – Edgar Brown Nov 16 '18 at 22:08
  • \$\begingroup\$ 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). \$\endgroup\$ – 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.

Here's a block diagram of what you want to achieve (sorry for the crappy picture). I can't remember my Simulink well enough to say exactly how to do it -- I suspect you can make a multi-input, multi-output block, but if you can't you can make a concatinated input vector with x and u, and concatenate y and x-dot in the output, and use muxing and demuxing to get the data in and out.

enter image description here

| improve this answer | |
  • \$\begingroup\$ Thanks for the answer. The diagram is great, helped me understand what you meant. However, could you expand a little on how you came to the conclusion that the function is coughing up the derivative of x and not x itself? \$\endgroup\$ – rrz0 Nov 17 '18 at 17:05
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – TimWescott Nov 17 '18 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.