0
그래서 핸들을 사용하여 콜백 함수 (select_cmp_Callback
), 생성 된 배열 (아래)을 작성 함수 (bot_igntmassflux_1_CreateFcn)에 호출하려고합니다. 하지만 분명히 실패하고 계속 말하고있다. Undefined function or variable "cmp_list".
GUIDE를 사용하여 한 함수에서 다른 함수로 값을 호출하는 방법은 무엇입니까?
감사합니다.
% --- Executes on button press in select_cmp.
function select_cmp_Callback(hObject, eventdata, handles)
[FileName,PathName] = uigetfile({'*.cmp',...
'Component Files (*.cmp)';'*.txt', 'Text Files (*.txt)';...
'*.*','All Files (*.*)'},'Select the Components File'); %add default path
if isequal(FileName,0)
disp('User selected Cancel')
else
disp(['User selected ', fullfile(PathName, FileName)])
copyfile(fullfile(PathName, FileName));
fdd = fopen(FileName);
file_strings = textscan(fdd, '%s', 'Delimiter', ':');
fclose(fdd);
delete(FileName);
file_strings_sz=size(file_strings{1}); %size of file_strings (number of rows)
file_strings_ix=0;
cmp_ix=0;
while file_strings_ix < file_strings_sz(1,1)
file_strings_ix = file_strings_ix+1;
if strcmp(file_strings{1}{file_strings_ix},'COMPONENT')
file_strings_ix = file_strings_ix+1;
cmp_ix=(cmp_ix)+1;
cmp_list{cmp_ix,1} = cellstr(file_strings{1}{file_strings_ix});
file_strings_ix = file_strings_ix+1;
end
end
end
disp(cmp_list);
handles.cmp_list = cmp_list;
function bot_igntmassflux_1_CreateFcn(hObject, eventdata, handles)
cmp_list = handles.cmp_list;
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
set(hObject,'String',cmp_list);
을 미안하지만 당신의 마음을합니까 ... 많은 이해가되지 않습니다 여전히보고 그것을 자신을 일을 시도했지만 : 당신이
handles
를 업데이트 할 경우는 GUI 함수의 끝에서 다음 명령을 사용하여 조금 더 설명해 주시겠습니까? –
먼저,'select_cmp_Callback'의 마지막 줄에 명령을 추가해야합니다. 어쨌든, 나는'bot_igntmassflux_1_CreateFcn'이 GUI가 열릴 때 호출된다는 것을 알기 때문에 당신이 무엇을하려고하는지 잘 이해하지 못한다. – ThP
Oh soo는 cmp_list가 createfcn에있는 옵션을 추가하려고 할 때 가 선택됩니다. 그러나 나는 여전히 같은 오류를 겪고있다. –