Select specific elements in a cell array
조회 수: 8 (최근 30일)
이전 댓글 표시
SreeHarish Muppirisetty
2014년 9월 19일
댓글: SreeHarish Muppirisetty
2014년 9월 19일
Hi
I have a cellarray variable 'noisyobs', whose length is 15.
noisyobs{1 to 4}..size of each one is 1X1800.
noisyobs{5 to 15}..size of each one is 1X60.
Now I want to do as described below:
% for loop running as many times as noisyobs cell array length
for eachindexvalue=1:length(noisyobs)
% assign to a new cell array variable whose length is always 14 (one less than length(noisyobs)
% i.e.,
newnoisyobs=noisyobs{?}; % Where I assign all the elementsof noisyobs except of the index 'eachindexvalue' % to new cellarray variable newnoisyobs
end %end for loop
How can I achieve this?
Thank you for your time
If not clear, will try to explain with more clarity.
Harish
채택된 답변
Image Analyst
2014년 9월 19일
Try this (untested):
for k=1:length(noisyobs)
allIndexes = 1 : length(noisyobs);
% Remove the kth one:
allIndexes(k) = [];
% Assign what's left:
% Put the whole 14 element cell array into the kth cell of a new cell array.
newnoisyobs{k} = noisyobs(allIndexes);
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!