Effacer les filtres
Effacer les filtres

Load structure without delete variable

2 vues (au cours des 30 derniers jours)
Alberto Mora
Alberto Mora le 26 Mai 2017
Commenté : Alberto Mora le 26 Mai 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?

Réponse acceptée

Jan
Jan le 26 Mai 2017
Modifié(e) : Jan le 26 Mai 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.
  1 commentaire
Alberto Mora
Alberto Mora le 26 Mai 2017
Thank you very much Jan Simon!!!!!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by