How to remove columns from a cell within in a structure

3 visualizaciones (últimos 30 días)
Cameron Swanson
Cameron Swanson el 2 de Oct. de 2019
Comentada: Cameron Swanson el 14 de Oct. de 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

Respuestas (1)

Harsha Priya Daggubati
Harsha Priya Daggubati el 10 de Oct. de 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

Categorías

Más información sobre Structures en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by