How can I properly load a file from current folder to workspace?

5 ビュー (過去 30 日間)
Veronika
Veronika 2015 年 2 月 23 日
コメント済み: Veronika 2015 年 2 月 23 日
Dear all
I have this code:
%
if exist ('netrb')
load netrb
disp('Neuronová síť byla načtena')
else
load trenovaci_modely1
disp('Trénovací modely byly načteny')
P = [c{1,:}];
T = [c{2,:}];
net = newrb(P,T,0,0.3);
end
save netrb net
disp('Neuronová síť byla uložena')
I would like to load netrb from my current folder, but always when I run this code, it starts to train network as if none exist in my folder. Please advise me, what´s wrong?

採用された回答

Stephen23
Stephen23 2015 年 2 月 23 日
編集済み: Stephen23 2015 年 2 月 23 日
Can you see netrb listed when you use dir in the command window?
You should read the documentation for exist: it is recommended to use both the input and output specifiers to explicitly define what kind of thing you are checking for. Use this to check for a file:
2==exist(...,'file')
You should also specify the filename complete with file extension, as there could be other similar named functions or variables.
I would also recommend that you use the function syntax of load , like this:
load('netrb')
  3 件のコメント
Stephen23
Stephen23 2015 年 2 月 23 日
My pleasure! Did it help?
Veronika
Veronika 2015 年 2 月 23 日
Yes, it works perfectly.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by