필터 지우기
필터 지우기

how can I plot nested structure fields?

조회 수: 2 (최근 30일)
nirmala rajagopal
nirmala rajagopal 2017년 3월 22일
편집: Walter Roberson 2022년 8월 18일
I have the output as such:
>> y=spectrm(1).hata_pathloss_L50(1).ant_rec()
y = 197.1081 184.6407 175.9222
spectrm is a structure with fields 'freq', 'hata_pathloss_L50'{ht1, ht2, ht3} and receiver antenna height {htr1, htr2, htr3}. For each ht1, ht2 and ht3 there are htr1, htr2 and htr3 and for each freq there are ht1, ht2 and ht3. How to plot freq in x-axis and pathloss in y axis? the spectrm structure is also an array. say about 10. so there are around 10 freqs

답변 (1개)

Mehmet Burak Ekinci
Mehmet Burak Ekinci 2022년 8월 18일
편집: Walter Roberson 2022년 8월 18일
As far as i know there is no built in support for getting values or plotting nested structure arrays.
I recently uploaded my custom matlab functions in file exchange:
It is for plotting and getting values of large nested struct arrays and it applies to your problem.
clear spectrm
% create example struct array based on your explanation
for i = 1:10
spectrm(i,1).freq = i;
spectrm(i,1).hata_pathloss_L50(1).ant_rec = (1:3)*i;
spectrm(i,1).hata_pathloss_L50(2).ant_rec = (4:6)*i;
spectrm(i,1).hata_pathloss_L50(3).ant_rec = (7:9)*i;
end
% retreive struct array elements
freqs = getNestedField(spectrm,'freq');
losses = getNestedField(spectrm,'hata_pathloss_L50.ant_rec');
% use struct array plotter (you may also use "plot(freqs,losses)")
plotStructArray(spectrm,'hata_pathloss_L50.ant_rec',freqs);
% your data will be plotted in order of
% ht1.htr1, ht1.htr2, ht1.htr3, ht2.htr1, .... ht10.htr1, ht10.htr2,
% ht10.htr3

카테고리

Help CenterFile Exchange에서 Antennas, Microphones, and Sonar Transducers에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by