Is it possible to declare and function within another function? if not, Look at the code below
조회 수: 1 (최근 30일)
이전 댓글 표시
% --- Executes on button press in Browse1.
function Browse1_Callback(hObject, eventdata, handles)
ExPath1 = fullfile(FilePath, FileName)
set(handles.Filename1,'string',ExPath1)
%-----------------------------------------------------------------------------
(I am trying use the ExPath1 variable from my Browse function in my calculate function, IS IT POSSIBLE TO USE THE ExPath1 VARIABLE? because I need it in order to do the calculation.)
%-----------------------------------------------------------------------------
%Calculate button code
function Calculate1_Callback(~, ~, ~)
[x, error, stat1, stat2, stat3] = correctionModelworking1(ExPath1,'true',2,'true');
댓글 수: 0
채택된 답변
Walter Roberson
2013년 6월 3일
편집: Walter Roberson
2013년 6월 3일
More specifically:
function Calculate1_Callback(~, ~, handles)
ExPath1 = get(handles.Filename1, 'string');
x, error, stat1, stat2, stat3] = correctionModelworking1(ExPath1,'true',2,'true');
Provided, that is, that your callback is being passed handles, as would be the case if you are using GUIDE.
댓글 수: 4
Walter Roberson
2013년 6월 4일
As I indicated in my code, you need
function Calculate1_Callback(~, ~, handles)
If you use my code as written then you will not need the "global"
추가 답변 (1개)
Sean de Wolski
2013년 6월 3일
You either have to pass it in as an input to the second function, or make the second function nested:
function foo(stuff)
a = pi;
function baz()
a = a+1;
end
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!