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,

 采纳的回答

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

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Search Path 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by