필터 지우기
필터 지우기

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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by