GUIDE Handle not updating
Ältere Kommentare anzeigen
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 Kommentare
Rik
am 14 Aug. 2020
Did you make sure antennaId_Callback runs before attenuationButton_Callback? And did you check the output of readAntenna?
Oliver Lestrange
am 14 Aug. 2020
Bearbeitet: Oliver Lestrange
am 14 Aug. 2020
Bruno Luong
am 14 Aug. 2020
Bearbeitet: Bruno Luong
am 14 Aug. 2020
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
am 14 Aug. 2020
Akzeptierte Antwort
Weitere Antworten (1)
Bruno Luong
am 14 Aug. 2020
Bearbeitet: Bruno Luong
am 14 Aug. 2020
Try to put this
[handles.Antenna(:).Info] = deal(readAntenna(selected,currDir));
in antennaId_Callback. (NOTE: You must call insertAntenna_Callback first).
2 Kommentare
Oliver Lestrange
am 14 Aug. 2020
Bruno Luong
am 14 Aug. 2020
Bearbeitet: Bruno Luong
am 14 Aug. 2020
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..
Kategorien
Mehr zu Phased Array Design and Analysis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!