Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Import connected cell values into an array

1 vue (au cours des 30 derniers jours)
Brendan Görres
Brendan Görres le 1 Oct 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hey guys,
I am trying to import certain data from a 1756x2 cell array "aParts" into a vector. The cell array contains element numbers in one column and the related label in the second column. The purpose is to store every element with the same label in one vector.
What I have already done is to create an array where the indices for example for the label "Cavity" are stored.
Now i would like to export every element (from "aParts" column 1) where "aCavla" is 1 into a new vector. How can I do that?
Here is the code I got so far
for idx = 1:ilEle %Create Matrix with Elements and related label
aParts{idx,1}= (aElements(idx));
aParts{idx,2}= (aName(idx));
aCavla{idx}=strfind(aParts{idx,2},'Cavity');
end
ilEle is a the length of th cell array "aParts", so in this particular example it equals 1756.
Thanks in advance
  1 commentaire
Stephen23
Stephen23 le 1 Oct 2020
You don't need a loop, either use accumarray or splitapply:

Réponses (0)

Cette question est clôturée.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by