Borrar filtros
Borrar filtros

Load structure without delete variable

2 visualizaciones (últimos 30 días)
Alberto Mora
Alberto Mora el 26 de Mayo de 2017
Comentada: Alberto Mora el 26 de Mayo de 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?

Respuesta aceptada

Jan
Jan el 26 de Mayo de 2017
Editada: Jan el 26 de Mayo de 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.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by