[問題]有關矩陣&cell迴圈問題

看板MATLAB作者 (Jolinda)時間11年前 (2014/01/02 13:33), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
小妹我最近要跑Apriori, 我要把跑出來的結果印出來 Rules矩陣是一個2x1的cell,裡面分別是2000x1 我load一個6x240的矩陣(裡面無空值)有error 以下程式碼: for i = 1:size(Rules{1},1) s1 = ''; s2 = ''; for j = 1:size(Rules{1}{i},2) if j == size(Rules{1}{i},2) s1 = [s1 labels{Rules{1}{i}(j)}]; else s1 = [s1 labels{Rules{1}{i}(j)} ',']; end end for k = 1:size(Rules{2}{i},2) % ()一般矩陣 {}cell if k == size(Rules{2}{i},2) s2 =[s2 labels{Rules{2}{i}(k)}]; %Index exceeds matrix dimensions. 索引超過矩陣範圍,可能有空矩陣 else s2 = [s2 labels{Rules{2}{i}(k)} ',']; end end 會出現Index exceeds matrix dimensions.的錯誤訊息 請問各位大大,該怎麼解決呢? 還是有其他寫法比較適當? Please give me a feedback. Thanks a lot. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.80.22
文章代碼(AID): #1InFeoXA (MATLAB)
文章代碼(AID): #1InFeoXA (MATLAB)