Matlab script of the Simulink continuous-time integral

8 vues (au cours des 30 derniers jours)
Khim Chhantyal
Khim Chhantyal le 28 Jan 2019
Hi,
I am trying to rewrite a Simulink block codes into a MATLAB script. I am not sure how the Simulink continusous-time integral works.
Here are first five rows of my inputs and outputs of the Simulink continuous integral block:
Integral inputs : [0,-10061562.4942636,14046.7032856068,11854.0747457453,8494.70586350615]
Integral outputs : [10,105812.741557873,6954.67061976904,8336.63324037146,9344.78029589033]
I am using fixed-step size of 0.1 in Simulink and initial value of the integral block is 10.
I have tried,
Capture2.PNG
and used Backward Euler method to approximate x_dot
2) trapezoidal method described in http://radio.feld.cvut.cz/matlab/toolbox/simulink/ug/discretetimeintegrator.html
Capture.PNG
My analysis so far,
a) Both of these methods does not exactly work like the Simulink Integral
b) At least for input and output combinations after 3rd iteration, the trapezoidal method works.
Can anyone help me, where i am making error? or is there other way to do it?
Thanks :)

Réponses (1)

Khim Chhantyal
Khim Chhantyal le 29 Jan 2019
Modifié(e) : Khim Chhantyal le 29 Jan 2019
I figure out the problem. :)
The error exists due to the step-size. Changing from 0.1 to 0.001 solved my issue. Make sense :)
-KC

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by