load function sometimes alters structure name in the Workspace
조회 수: 3 (최근 30일)
이전 댓글 표시
I am encountering a weird phenomena where using the load('filename') function to load a structure, alters the structure name in the workspace. This does not occur everytime, but I observed it on multiple occasions:
Example:
close all
clear variables
load('TM24_w')
results in a structure in my workspace named: "TM242_w"
It does load in the correct structure with the correct fields and values but the workspace name is wrong.
Has anyone ever encountered this and is there a solution?
댓글 수: 5
채택된 답변
Walter Roberson
2020년 7월 21일
When you load a mat file without output on the load command, the variable names will be the same as the names inside the mat and not what the file name happens to be.
댓글 수: 3
Stephen23
2020년 7월 21일
편집: Stephen23
2020년 7월 21일
"What do you mean by the "names inside the mat"?"
.mat files store one or more variables (or fields of a structure). Variables have names.
The name of the file is irrelevant.
Note that the MATLAB documentation recommends loading into an output variable.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!