Set initial value in Matlab Function block
Mostra commenti meno recenti
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 Commenti
William
il 17 Apr 2014
Azzi Abdelmalek
il 17 Apr 2014
What do you mean? the same single element each iteration, or the first, then the second, and so on ?
William
il 17 Apr 2014
Azzi Abdelmalek
il 17 Apr 2014
have you tried Ports and Data Manager?
William
il 17 Apr 2014
Risposte (2)
Azzi Abdelmalek
il 17 Apr 2014
Modificato: Azzi Abdelmalek
il 17 Apr 2014
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 Commenti
William
il 17 Apr 2014
Azzi Abdelmalek
il 17 Apr 2014
UP1 does not exist (The answer was edited) UPI1 is an intermediate variable
William
il 17 Apr 2014
Azzi Abdelmalek
il 17 Apr 2014
Modificato: Azzi Abdelmalek
il 17 Apr 2014
What UL and other variables represent? If they are constants from workspace, use Ports and Data Manager
William
il 17 Apr 2014
Azzi Abdelmalek
il 17 Apr 2014
What is the size of UL?
William
il 17 Apr 2014
Azzi Abdelmalek
il 17 Apr 2014
its sapling size is inf ? what is that ?
William
il 17 Apr 2014
William
il 17 Apr 2014
William
il 19 Mag 2014
Modificato: Azzi Abdelmalek
il 19 Mag 2014
Danilo Teran
il 4 Dic 2018
1 voto
Hi
I have a similar problem, could you find a real solution.
Best regards?
Categorie
Scopri di più su Event Functions in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!