load function sometimes alters structure name in the Workspace

1 回表示 (過去 30 日間)
Jon-Danilo Kortram
Jon-Danilo Kortram 2020 年 7 月 21 日
編集済み: Stephen23 2020 年 7 月 21 日
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 件のコメント
Jon-Danilo Kortram
Jon-Danilo Kortram 2020 年 7 月 21 日
Again it's the name of the structure that changed. The variables inside the structure are fine.
Stephen23
Stephen23 2020 年 7 月 21 日
編集済み: Stephen23 2020 年 7 月 21 日
"Again it's the name of the structure that changed. The variables inside the structure are fine. "
Very unusual. Can you please upload the .mat file by clicking the paperclip button.
What OS are you using?

サインインしてコメントする。

採用された回答

Walter Roberson
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
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.
Jon-Danilo Kortram
Jon-Danilo Kortram 2020 年 7 月 21 日
loading directly into an output variable is a good solution, thank you

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by