Filter löschen
Filter löschen

How to get rid of gaps in my structure?

2 Ansichten (letzte 30 Tage)
JamJan
JamJan am 18 Jun. 2019
Beantwortet: KSSV am 18 Jun. 2019
Hi,
I have the following structure (see below) and I want to get rid of the gaps. How can I get rid of the empty places and align the structures with content underneath each other?
Structure:
[]
1x182 double
1x28 double
[]
1x3299 double
1x36 double
[]
1x173 double
[]
[]
1x34 double
1x32 double
1x64 double
[]

Akzeptierte Antwort

KSSV
KSSV am 18 Jun. 2019
S = struct ;
for i = 1:2:10
S(i).val = rand(10,1) ;
end
% GEt the empty structures
idx = find(arrayfun(@(S) isempty(S.val),S));
% Remove empty structures
S(idx) = []

Weitere Antworten (1)

Raj
Raj am 18 Jun. 2019

Kategorien

Mehr zu Structures finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by