The issue of the if statement is resolved. Is there any block to extract a single element from the vector (entered from "From Workspace" block) to set as the input to the ML Fctn block?
Set initial value in Matlab Function block
29 ビュー (過去 30 日間)
古いコメントを表示
How can I set the initial value for UP? UPI is my initial value input to the block. How can I make sure UP will accepts thhs value only once (start of the simulation)? Thanks
funciton UP=[UPI]
*UP=UPI;
%#close safety_relieve_valve
SRV=0;
if (UP>UL)
Val=0;
UP=RD;
else
Val=1;
UP=RU;
end
if (UP<LL) & (Val==0)
UP=RD+0.1;
disp(UP);
Val=1;
elseif (UP>=LL) & (Val==1)
UP=UP+0.1;
end*
5 件のコメント
回答 (2 件)
Azzi Abdelmalek
2014 年 4 月 17 日
編集済み: Azzi Abdelmalek
2014 年 4 月 17 日
You can use persistent declaration
function UP=fcn(UPI)
persistent UPI1
if isempty(UPI1)
UP=UPI
else
UP=UPI1
end
%your code
UPI1=UP;
11 件のコメント
Danilo Teran
2018 年 12 月 4 日
Hi
I have a similar problem, could you find a real solution.
Best regards?
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Programmatic Model Editing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!