フィルターのクリア

Problems with Nested functions

1 回表示 (過去 30 日間)
Hanif
Hanif 2013 年 5 月 21 日
having lots of trouble with my program, alot of them would be solved if I could use nested functions, however my program will not let me use nested functions. Why? and anyways around this?
Function startup
load Exampledata.mat
function example
disp('hello world')
end
end
something even this simple will not work! Error result is
Error using load Attempt to add "clims" to a static workspace. See MATLAB Programming, Restrictions on Assigning to Variables for details.
Error in program (line 3) load ExampleData.mat

採用された回答

Matt J
Matt J 2013 年 5 月 21 日
編集済み: Matt J 2013 年 5 月 21 日
Call LOAD with an explicit output instead. Not doing so is bad for many reasons in addition to the error that it's giving you here.
Function startup
S=load('Exampledata.mat');
function example
disp('hello world')
end
end
  2 件のコメント
Hanif
Hanif 2013 年 5 月 22 日
Thanks that seems to do the trick, however anytime I try and call a variable in Exampledata.mat it is now undefined?
Matt J
Matt J 2013 年 5 月 22 日
編集済み: Matt J 2013 年 5 月 22 日
The variables are fields of the structure output S. You should access them through that.

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 5 月 21 日
Check if ExampleData.mat is in your current folder
dir ExampleData.mat

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by