Azzera filtri
Azzera filtri

Load structure without delete variable

2 visualizzazioni (ultimi 30 giorni)
Alberto Mora
Alberto Mora il 26 Mag 2017
Commentato: Alberto Mora il 26 Mag 2017
Hi everybody. In my code, I load from a FileName.mat file the strucure "matrix." that contain matrix A, B and C. However in my script I load several time this file because I manipulate it, so I need to load the "original" version to compute different analysis. In addiction in my code I compute "matrix.D". The problem is that everytime that I load FileName.mat file, all variable conteined in the strucure "matrix." are deleted (and so also "matrix.D" that must be the same for all analysis). Is there a method to load a strucure, without delete the other variable contained in the strucure?

Risposta accettata

Jan
Jan il 26 Mag 2017
Modificato: Jan il 26 Mag 2017
Yes, there is a method. Simply use another variable:
matrixReloaded = load('FileName.mat');
matrix.A = matrixReloaded.A;
matrix.B = matrixReloaded.B;
matrix.C = matrixReloaded.C;
But if you create a copy already, why not keeping in directly?
matrix = load('FileName.mat');
matrix.A_Orig = matrix.A;
matrix.B_Orig = matrix.B;
matrix.C_Orig = matrix.C;
Then restoring the original values are available without reloading.

Più risposte (0)

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by