? grouping data in MatLab

看板Programming作者時間18年前 (2006/07/01 03:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
Hi: I need to deal data using MatLab and the data is as follows. Data has: x, y, z, Type, and Val arrays, the number of data is: NoData The content of Type is 1 or 2. I need to do some process ONLY for those data whose Type == 1, and then do some process for those data whose Type == 2. More sepcifically, % Loop-1 for n = 1st data whose Type == 1 to the last data whose Type == 1 some processing end % Loop-2 for n = 1st data whose Type == 2 to the last data whose Type == 2 some processing end How do I do this in MatLab efficiently? Note, it is NOT allowed to do any processing in Loop-2 before those processing in Loop-1 are completed. The easiest approach is: for n = 1:1:NoData if Type(n) == 1 do processing type-1 end end % n loop for n = 1:1:NoData if Type(n) == 2 do processing type-2 end end % n loop But this is not very efficient, especially NoData is about 10^6 to 10^7. Thanks, by Cheng Cosine Jun/30/2k6 NC -- ┌─────KKCITY─────┐  線上音樂新震撼   bbs.kkcity.com.tw ^_^ / 隨選隨播免等待 KKBOX ^_^ / └──From:152.16.233.74 ──┘   http://www.kkbox.com.tw   --
文章代碼(AID): #14fNJk00 (Programming)
文章代碼(AID): #14fNJk00 (Programming)