How to remove columns from a cell within in a structure

5 Ansichten (letzte 30 Tage)
Cameron Swanson
Cameron Swanson am 2 Okt. 2019
Kommentiert: Cameron Swanson am 14 Okt. 2019
Hello,
I have a total of N photogroups each with I photos represented within a structure s which contains sub-structures and cells. Each photogroup is a struct inside a 1xN cell and each photo is a struct within a cell of the photogroup struct. Confusing I know.. It's easier to just look at the code below
I want to delete all but the first photo in each photogroup and effectively resize the photogroup struct to only include the first photo. The code allows me to delete the photos I don't want but the empty cells are filled with []. Is there a way to do this and remove the [] cells completely?
N and I are predefined.
Thanks in advance,
Cameron
for n=1:N %number of photogroups
for i=2:I %number of images except the first
%delete
s.BlocksExchange.Block.Photogroups.Photogroup{1, n}.Photo{1, i}=[];
end
end

Antworten (1)

Harsha Priya Daggubati
Harsha Priya Daggubati am 10 Okt. 2019
Hi,
I guess you can try doing:
for n = 1:N % number of photogroups
% delete
s.BlocksExchange.Block.Photogroups.Photogroup{1, n}.Photo = s.BlocksExchange.Block.Photogroups.Photogroup{1, n}.Photo{1, 1};
end

Kategorien

Mehr zu Images 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