How to save persistent variables after the last call to the function?
2 views (last 30 days)
Show older comments
MAHABUB HASAN MAHALAT on 27 Feb 2017
Edited: MAHABUB HASAN MAHALAT on 28 Feb 2017
I have a function with some persistent variables, when I am writing the persistent variables (using save command) during each call to the function than it is working fine but when I am using if else logic to write the variables only at the last call to the function then Matlab storing the variables as empty. I have attached the required code segment.
store_counter = 0;
store_fitness = ;
save stor_chrom1.mat stor_chrom store_fitness;
% update persistent variables
Alexandra Harkai on 27 Feb 2017
Without using the save command the persistent variables could be declared as persistent when calling from a function, as explained in the documentation .
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!