Ignoring empty arrays when using arrayfun on a structure?
Afficher commentaires plus anciens
I have 1x2269 structure with 20 fields called data. I am trying to extract with a condition using arrayfun.
west_east = arrayfun(@(n) 110 >= data(n).TTA(1) & data(n).TTA(1) >= 70, 1 : length(data));
data = data(west_east);
The problem is that some of the arrays in my structure are empty. When I run the code, I am getting the error
Attempted to access data2.TTA(1); index out of bounds because
numel(data2.TTA)=0.
I understand that this is due to having empty cells in my structure such as
data2(9)
ans =
type: 'B738'
time: [0x1 double]
lat: [0x1 double]
lng: [0x1 double]
altitude: [0x1 double]
selected_altititude: [0x1 double]
BPS: [0x1 double]
RA: [0x1 double]
TTA: [0x1 double]
GS: [0x1 double]
TAR: [0x1 double]
TAS: [0x1 double]
heading: [0x1 double]
IAS: [0x1 double]
Mach: [0x1 double]
BAR: [0x1 double]
IVV: [0x1 double]
wind: [0x1 double]
real_time: []
instantaneous_GS: []
displacement: []
How can I adjust my code to get what I want? Thanks.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!