Select specific elements in a cell array
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
SreeHarish Muppirisetty
le 19 Sep 2014
Commenté : SreeHarish Muppirisetty
le 19 Sep 2014
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
Réponse acceptée
Image Analyst
le 19 Sep 2014
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Cell Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!