How to remove columns from a cell within in a structure

5 views (last 30 days)
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

Answers (1)

Harsha Priya Daggubati
Harsha Priya Daggubati on 10 Oct 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

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!