필터 지우기
필터 지우기

Load structure without delete variable

조회 수: 2 (최근 30일)
Alberto Mora
Alberto Mora 2017년 5월 26일
댓글: Alberto Mora 2017년 5월 26일
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?

채택된 답변

Jan
Jan 2017년 5월 26일
편집: Jan 2017년 5월 26일
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
Alberto Mora
Alberto Mora 2017년 5월 26일
Thank you very much Jan Simon!!!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by