Why when i load workspace manually the code works but when i try to load it from code doesn't?

7 ビュー (過去 30 日間)
Im trying to load some workspace variables for a neural network from code by using this
S0 = load('mynet.mat');
but when i run it i get this error:
Undefined function or variable 'myNet'.
Error in transfer (line 46)
nnet = myNet; % Load the neural net
If i am loading it manually and run it i have no problems. Why and how can i make it work from code?
  3 件のコメント
Niculai Traian
Niculai Traian 2018 年 7 月 4 日
I need explications. why did this work? what is the difference? Also thanks. It worked
Adam
Adam 2018 年 7 月 4 日
You can see your workspace in Matlab. Just take a look at it and you'll see your struct.

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

採用された回答

Dennis
Dennis 2018 年 7 月 4 日
編集済み: Dennis 2018 年 7 月 4 日
If you use load('mynet.mat') in command line you will load all variables in mynet.mat to your workspace. Hence myNet will exist if it is a variable in mynet.mat.
If you assign S0=load('mynet.mat') you will create a structure S0 that contains all variables stored in mynet.mat. myNet does not exist because it is part of S0.
myNet=S0.myNet; %creates a variable myNet with the content of S0.myNet
  1 件のコメント
Stephen23
Stephen23 2018 年 7 月 4 日
Additional to that: it is recommended to load into the output structure, and then access its fields. Read this to know why:
So the best solution is:
S = load(...)
S.myNet % access your data

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by