How to remove columns from a cell within in a structure
조회 수: 5 (최근 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
댓글 수: 0
답변 (1개)
Harsha Priya Daggubati
2019년 10월 10일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!