看板 MATLAB 關於我們 聯絡資訊
請問我有多個.mat files (sample_01.mat, sample_02.mat ...etc), 每一個mat file 都是矩陣相同的 (假設是2 x 2) 請問我要如何把多個mat. files想加? sample_01.mat = [1 2;3 4] sample_02.mat = [2 3;4 5] 想要得到1+2 最後變成 [3 5; 7 9] 的另一個.mat file ? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.165.158.104 ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1550243228.A.B49.html
shuncheng: load 處理後在儲存 02/15 23:11
profyang: load進來 看他變數是啥 然後在Matlab裡相加 02/16 14:25
profyang: 相加後再用save存新的.mat 02/16 14:25
riviera: 可是有50~60個mat files,有辦法for loop嗎? 02/16 19:21
profyang: 那就要看你取名有沒有規律阿 或者你把那50個.mat放到空 02/16 21:39
profyang: 白資料夾 然後用dir類的抓出所有mat檔名 然後讀出來慢慢 02/16 21:40
profyang: 加 02/16 21:40
profyang: 例如 D=dir('你的資料夾位置'); 然後for迴圈裡用 02/16 21:41
profyang: D(i).name之類的把一個個mat檔名叫出來load 02/16 21:41