Represent Simulink Integrator block as Matlab Function
古いコメントを表示
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.
採用された回答
その他の回答 (4 件)
Azzi Abdelmalek
2012 年 12 月 7 日
編集済み: Azzi Abdelmalek
2012 年 12 月 8 日
2 投票
I don't know why do you need this, maybe if you explain exactly what you need, there is better way
9 件のコメント
River Rock
2012 年 12 月 8 日
Azzi Abdelmalek
2012 年 12 月 8 日
編集済み: Azzi Abdelmalek
2012 年 12 月 8 日
You can't do it
River Rock
2012 年 12 月 8 日
Azzi Abdelmalek
2012 年 12 月 8 日
What about time t?
Azzi Abdelmalek
2012 年 12 月 8 日
Can you post the solution?
Azzi Abdelmalek
2012 年 12 月 8 日
編集済み: Azzi Abdelmalek
2012 年 12 月 8 日
It works with Ryan's hint, but you still need a clock as an input.
River Rock
2012 年 12 月 8 日
編集済み: River Rock
2012 年 12 月 8 日
Azzi Abdelmalek
2012 年 12 月 8 日
編集済み: Azzi Abdelmalek
2012 年 12 月 8 日
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;
River Rock
2012 年 12 月 8 日
Guy Rouleau
2012 年 12 月 5 日
0 投票
This is not a good idea. The MATLAB function is not designed for this purpose.
1 件のコメント
Edward Rodriguez
2020 年 8 月 10 日
Excuse me, so, What would be a good idea to implement numerical integration methods in blocks in Simulink?
River Rock
2012 年 12 月 5 日
編集済み: River Rock
2012 年 12 月 6 日
0 投票
4 件のコメント
Ryan G
2012 年 12 月 5 日
Why do you need to use MATLAB over SL blocks? Look into the persistent variables, it will get the job done, although as Guy mentioned, it's not the best way to do it.
River Rock
2012 年 12 月 5 日
Ryan G
2012 年 12 月 5 日
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
2012 年 12 月 7 日
River Rock
2012 年 12 月 5 日
0 投票
1 件のコメント
Kiran Mahmood
2018 年 10 月 21 日
I'm working on a similar problem. Did u find the solution ? Need help.
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!