MATLAB Answers


How to compare workspace variable to variable saved on disk and save if different.

Asked by Octavian on 28 Jan 2015
Latest activity Edited by Octavian on 28 Jan 2015
Dear All,
here is my challenge. I use an script that generates an output variable varx in workspace and saves it to a binary file filey (location path/filey) every time it is run, overriding the prior save.
I want that with each run, the script generates the new varx, and compares it automatically with the saved varx in filey.mat. If the two are identical (not just the name, but identical in all attributes), then the new varx should not be saved as there is no point.
If the two are not identical, the I want to change the name of the saved (old) filey mat wrapper to filey_d, where d is the date of 'last modified' as in Windows explorer (If this is difficult, another option would be to change filey name to filey_d, where d is the current date); and save the current varx in workspace in a new filey binary ('filey' name is not dynamic). A such, the filey would include the most recent varx, which could be imported and processed by the script later, but old varx-es would be stored as well on disk. Also, I do not want to change the old varx name, but the name of its wrapper binary (filey).
I mention that varx data types are double matrices, figures, and cell arrays.
Thank you for assist,


Sign in to comment.

0 Answers