GUIDE Handle not updating
이전 댓글 표시
Hi,
I am using the following code.
function antennaId_Callback(hObject, eventdata, handles)
% hObject handle to antennaId (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns antennaId contents as cell array
% contents{get(hObject,'Value')} returns selected item from antennaId
contents = cellstr(get(hObject,'String')) % Options of popupmenu antennaId
selected = contents{get(hObject,'Value')} % Value selected by the user through popupmenu antennaId
currDir = strcat(pwd,'\')
handles.Antenna.Info = readAntenna(selected,currDir);
guidata(hObject, handles);
And then, when I call it here
function attenuationButton_Callback(hObject, eventdata, handles)
% hObject handle to attenuationButton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%global ant; % Default Antenna
Aten=0;
handles = guidata(hObject)
handles.MS(1).x = 1:handles.map.xlength;
handles.MS(1).y = 1:handles.map.ylength;
handles.MS(1).height = 1.5; %m
handles.MS(1).gain = 2.4;
for i = 1:handles.nAntenna
Aten=Aten+1
handles.Antenna(i).Prx=attenuation( handles.map, handles.Antenna(i), handles.MS,...
handles.Antenna(i).Info);
end
Aten=1;
guidata(hObject, handles);
The variable handles.Antenna.Info exits, but in the loop it sends an empty array. At the first call has the handles.Antenna.Info, but the second time doesn't.
What I am doing wrong?
Thanks
댓글 수: 4
Rik
2020년 8월 14일
Did you make sure antennaId_Callback runs before attenuationButton_Callback? And did you check the output of readAntenna?
Oliver Lestrange
2020년 8월 14일
편집: Oliver Lestrange
2020년 8월 14일
Bruno Luong
2020년 8월 14일
편집: Bruno Luong
2020년 8월 14일
Who initializes handles.nAntenna ? Why antennaId_Callback initializes a single structure Antenna and attenuationButton_Callback use structure array (without MATLAB throwing an error)? What is "Aten", why it's not used anywhere?
It seems you still don't tell us the whole story.
Oliver Lestrange
2020년 8월 14일
채택된 답변
추가 답변 (1개)
Bruno Luong
2020년 8월 14일
편집: Bruno Luong
2020년 8월 14일
Try to put this
[handles.Antenna(:).Info] = deal(readAntenna(selected,currDir));
in antennaId_Callback. (NOTE: You must call insertAntenna_Callback first).
댓글 수: 2
Oliver Lestrange
2020년 8월 14일
Bruno Luong
2020년 8월 14일
편집: Bruno Luong
2020년 8월 14일
DEAL will populate all the field Info of handles.Antenna structure array using a single output argument returned by readAntenna.
Now "Dind't work" alone doesn't allow me do make any useful comment/diagnostic. But I suspect is you call insertAntenna_Callback AFTER antennaId_Callback contraty to the instruction I gave. Since that will create a new structure at the end of the array and leaves Info field unpopulated, meaning having EMPTY as default value.
Anyway if you are happy with Walter's answer, then it's OK..
카테고리
도움말 센터 및 File Exchange에서 Phased Array Design and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!