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!