How can I split my data into categories

Hi I have a cell data imported from Excel (variable name and corresponding class) like that
['AN1','ASA','AND','ANL','ABB','ACD','ACH','ACK','AYT','ALD'];
['stock','stock','stock','stock','bond','bond','bond','bill','bill','bill']
I want to convert this to structure or any useful type to apply a function to specified class. In other words, I want to apply a function to variables under each ('stock', 'bond', 'bill') class.
Thanks,

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 22 de Jul. de 2015
a={'AN1','ASA','AND','ANL','ABB','ACD','ACH','ACK','AYT','ALD'}
b={'stock','stock','stock','stock','bond','bond','bond','bill','bill','bill'}
[ii,jj,kk]=unique(b)
for k=1:numel(ii)
data.(ii{k})=a(ismember(kk,k))
end

Más respuestas (0)

Categorías

Más información sobre Search Path en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 22 de Jul. de 2015

Respondida:

el 22 de Jul. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by