Represent Simulink Integrator block as Matlab Function
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
River Rock
am 4 Dez. 2012
Kommentiert: Edward Rodriguez
am 10 Aug. 2020
Hi.
I need to implement the following behavior :

The Integrator and my_Integrator blocks have to be equivalent I/O.
How should I write the Matlab Function ?
Thanks for any reply.
2 Kommentare
Akzeptierte Antwort
Ryan G
am 4 Dez. 2012
As this looks like a homework problem, I can't answer directly. However I will point you in the direction of persistent variables.
0 Kommentare
Weitere Antworten (4)
Azzi Abdelmalek
am 7 Dez. 2012
Bearbeitet: Azzi Abdelmalek
am 8 Dez. 2012
I don't know why do you need this, maybe if you explain exactly what you need, there is better way
9 Kommentare
Azzi Abdelmalek
am 8 Dez. 2012
Bearbeitet: Azzi Abdelmalek
am 8 Dez. 2012
Ok, I see, If T is constant, you must then set, in model configuration parameters your fixed step time to T, and also your step block sample time to T. In this case you don't need a clock.
function y = fcn(u)
persistent uold yold
T=0.01;
if isempty(uold)
uold=0;yold=0;
end
y = u*T+yold-(u-uold)*T/2
yold=y;uold=u;
Guy Rouleau
am 5 Dez. 2012
This is not a good idea. The MATLAB function is not designed for this purpose.
1 Kommentar
Edward Rodriguez
am 10 Aug. 2020
Excuse me, so, What would be a good idea to implement numerical integration methods in blocks in Simulink?
River Rock
am 5 Dez. 2012
Bearbeitet: River Rock
am 6 Dez. 2012
4 Kommentare
Ryan G
am 5 Dez. 2012
What you have written is close it would be more like:
y(z) = yOld+u(z)/SampleTime
You cannot use the ODE solver in the MATLAB function block.
River Rock
am 5 Dez. 2012
1 Kommentar
Kiran Mahmood
am 21 Okt. 2018
I'm working on a similar problem. Did u find the solution ? Need help.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!