MATLAB Answers


Simulink model doesn't output the correct results for a ODE

Asked by Rajesh
on 26 May 2013

I'm trying to simulate a first order ODE(involving column vector) in simulink. I've written the code for differential equation in matlab files which gives the correct result.But when the same equation represented in simulink doesn't give the correct output.

So i want to know why the simulink model is behaving weirdly or i'm missing some options with simulink or its a bug with simulink.

I'm giving the links for the model and code here. # timeresponse.m # dof3.m # new3dof.slx #




No products are associated with this question.

1 Answer

Answer by Azzi Abdelmalek
on 26 May 2013
Edited by Azzi Abdelmalek
on 29 May 2013
 Accepted answer

The matrices in your simulink model are different from your script, in your simulink model set

Edit regarding to Jan's remarks

the first matrix to Mat1


the second matrix to Mat2


Also, in your scope parameters, uncheck limit data points to last under history

Also, add a gain block with value set to 180/pi to one of your first output


Jan Simon
on 26 May 2013

"inv(Mass) * M1" hurts the eyes, when one remembers, that "Mass\M1" is faster and more stable.

on 27 May 2013

Thanks for the answer, Mr.Abdelmalek . I corrected my matrix values (sorry for a silly mistake on my part). But still the graphs don't agree.Can you please point me where i'm doing it wrong?

Here's the link for updated version...

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!