what's a persistent variable????
Mostra commenti meno recenti
Hi
really I'm confused by persistent variables!!!
please help me to know what are they and their applications???
1 Commento
Walter Roberson
il 7 Mag 2012
Please do not use your own name as a Tag. Tags are intended to reflect categories of questions, so that people can easily find related questions that might be of interest to them. If you need to find your own questions you can use the My Questions link.
Risposta accettata
Più risposte (1)
Jan
il 7 Mag 2012
At first I suggest reading the documentation
doc persistent
help persistent
The you can try it:
function myFunc
persistent V
if isempty(V)
disp('V is empty');
disp('set V to 1');
V = 1;
end
V = V + 1;
fprintf('V = %d\n', V);
Save this file and start it through the command line:
myFunc
myFunc
myFunc
And now clear the function and call it again:
clear myFunc
myFunc
myFunc
Clearer now?
1 Commento
mohammad asasi
il 9 Mag 2012
Categorie
Scopri di più su Desktop in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!