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,

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 22 日

0 投票

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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by