How to remove columns from a cell within in a structure

1 次查看(过去 30 天)
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

回答(1 个)

Harsha Priya Daggubati
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

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by