Obtain sample time in Embedded Matlab block
1 回表示 (過去 30 日間)
古いコメントを表示
Sorry if this has been asked many times before, but I couldn't find an answer.
If I have an embedded Matlab block with inherited sample time, can I somehow obtain the evaluated sample time in the code of the embedded block at runtime? This is possible for an S-function and it would be really sweet if it was possible for embedded blocks as well.
0 件のコメント
回答 (3 件)
Ryan G
2012 年 7 月 30 日
I don't believe you can do this directly but you could use this code in the EML block with a clock as an input:
function y = fcn(u)
%#codegen
persistent time12
if isempty(time12)
time12 = 0;
end
deltaT = u - time12;
time12 = u;
y = deltaT;
Where the block is at the same inherited sample rate.
0 件のコメント
Azzi Abdelmalek
2012 年 7 月 30 日
編集済み: Azzi Abdelmalek
2012 年 7 月 30 日
you can use a "zoh" block (simulink/discret/Zero Order Holder), with a sample time of your choice. You place it at the inputs (or/and) outputs of the embedded matlab function block
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Simulink Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!