How to initialize outpt of a matlab function block in simulink to zero
21 ビュー (過去 30 日間)
古いコメントを表示
Hello all;
I have designed a control system for a robot manipulator using simulink which includes several matlab function blocks.
My question how is it possible to initialize the input of the controller τ to zero at the start of the simulink simulation
Thank you in advance for your help
Regards
0 件のコメント
回答 (1 件)
Gert Kruger
2019 年 6 月 19 日
編集済み: Gert Kruger
2019 年 6 月 27 日
You can add a persistent variable and check if it is empty. If it is empty, then it means it is the first time the Matlab function block is being executed, in which case you can set the output to be zero.
Example code:
function y = fcn(u)
persistent x
if isempty(x)
x = 1;
end
if (x==1)
y = 0; %y is 0 on the first simulation time step
else
y = 1; %y is 1 on for the rest
end
2 件のコメント
Gert Kruger
2019 年 6 月 27 日
編集済み: Gert Kruger
2019 年 6 月 27 日
lady bird,
perhaps you can upload your model if you are still having problems.
参考
カテゴリ
Help Center および File Exchange で General Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!