0
Matlab給我錯誤,「下標賦值尺寸不匹配」,但我認爲不應該有問題。代碼如下,但基本上我有一個臨時矩陣模仿另一個矩陣testData(實際上是它的一個子集)的維數。我可以將imread的輸出分配給臨時矩陣,但不能分配給具有相同維度的testData的子集。我甚至可以使用尺寸函數來證明它們是相同的尺寸,但一個可以工作,一個不可以。所以我設置temp = imread,然後testData = temp並且它工作。但爲什麼我必須這樣做呢?可能不正確的Matlab錯誤:「下標賦值尺寸不匹配」
fileNames = dir('Testing\*.pgm'); numFiles = size(fileNames, 1); testData = zeros(32257, numFiles); temp = zeros(32256, 1); for i = 1 : numFiles, fileName = fileNames(i).name; % Extracts some info from the file's name and stores it in the first row testData(1, i) = str2double(fileName(6:7)); % Here temp has the same dimensions as testData(2:end, i) % yet testData(2:end, i) = imread(fileName) doesn't work % however it works if I use temp as a "middleman" variable temp(:) = imread(fileName); testData(2:end, i) = temp(:); end
它實際上是灰度,但重塑事工作正常。謝謝。 – BluePlateSpecial 2011-04-08 03:24:15