Filter löschen
Filter löschen

Load structure without delete variable

2 Ansichten (letzte 30 Tage)
Alberto Mora
Alberto Mora am 26 Mai 2017
Kommentiert: Alberto Mora am 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?

Akzeptierte Antwort

Jan
Jan am 26 Mai 2017
Bearbeitet: Jan am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by