看板 MATLAB 關於我們 聯絡資訊
我的主要目的是產生一連串的檔案路徑 我嘗試過使用dir來建立一個list以讀取檔案‧ 不過由於我要使用的檔案是nii檔,實際上應該會有test1.nii,1、test1.nii,2、...... 如果使用dir的話只能找到test1.nii 所以後來改用for迴圈進行,但一直出現錯誤,想請大家幫忙看一下該怎麼改正。 謝謝‧ 檔案內容如下: ----- clear; clc; cwd=pwd; a1 = input('The Condition of 1-st run?\n','s'); %確認各RUN的CONDITION名稱 a2 = input('The Condition of 2-nd run?\n','s'); a3 = input('The Condition of 3-rd run?\n','s'); a4 = input('The Condition of 4-th run?\n','s'); cwd1 = [cwd,'\RS-test1(',a1,')\test1.nii,']; %設定各RUN的nii檔案路徑 cwd2 = [cwd,'\RS-test2(',a2,')\test2.nii,']; cwd3 = [cwd,'\RS-test3(',a3,')\test3.nii,']; cwd4 = [cwd,'\RS-test4(',a4,')\test4.nii,']; for i=1:10; list1(i) = [cwd1,num2str(i)]; end; ----- 錯誤訊息為: ??? Subscripted assignment dimension mismatch. Error in ==> test2 at 17 list1(i) = [cwd1,num2str(i)]; --- -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.116.183.173 ※ 文章網址: https://www.ptt.cc/bbs/MATLAB/M.1426592989.A.963.html
physbook: 用list1(i,:)試試看03/17 21:04
physbook: string是有長度的03/17 21:04
你好,謝謝你的建議。但依然會出現相同的Error。 ※ 編輯: shadow5402 (140.116.183.173), 03/18/2015 11:57:32
ejialan: 改成list1{i} = [cwd1,num2str(i)]; 用cell array存03/18 13:33
解決了!謝謝你的幫忙! ※ 編輯: shadow5402 (140.116.183.211), 03/18/2015 14:40:44 ※ 編輯: shadow5402 (140.116.183.173), 03/18/2015 15:23:50