When using MATLAB, you typically save the results of the calculation to a mat file. The command used is: Save filename
But when saved with the above command, the other variables in the calculation process are saved together. This coarse preservation has the following drawbacks:
(1) The unwanted data is saved to the mat file, which causes the mat file to be too large;
(2) The next time you load the mat file, it will display other unwanted data that consumes system memory.
Therefore, when you save the data, you should save the useful data variables.
Processing method:
(1) Delete the variable first, then save
For example, the variable a,b,c,d,e,f,g, you need to retain the value of a,e,f, you can use the command: Clear b c D; Then save filename
"Applicable" in the case of a few redundant variables, there are many variables saved.
(2) When saving, specify the saved variable
For example, variable a,b,c,d,...... A few hundred variables, you need to retain the value of a, you can use the command: Save filename A
The "Where applicable" redundancy variable is very numerous, saving fewer variables.
In addition , if you change a single, save the time, the back to add-append, so that will not overwrite the other.
How to preserve data for a specified variable in matlab