0
重塑我整形單元陣列時有一個問題
w = size(im,1); % width size
h = size(im,2);
d = size(crossfield,3);
for pxRow = 1:h % fixed pixel row
for pxCol = 1:w % fixed pixel column
for pxBreadth = 1:d
for r = 1:h % row of distant pixel
for c = 1:w % column of distant pixel
for z = 1:d
field(c,r,z) = crossfield(c,r,z).*rmatrix(c,r,z);
end
end
end
b(i) = {field}; % filling a cell array with results. read below
i = i+1;
end
end
end
b = reshape(b, w, h,z);
和錯誤:
Error using ==> reshape
To RESHAPE the number of elements must not change.
某些其他信息,其可以是使用的:
>> size(im)
ans =
35 35
>> size(crossfield)
ans =
35 35 3
>> size(rmatrix)
ans =
35 35 3
>> size(w)
ans =
1 1
我該如何重塑b?
你的代碼在我的機器上運行正常(當我調用'reshape'時沒有錯誤)。 'i'的初始值是多少?當你在運行循環之後執行size(b)'時,你會看到什麼?我在循環之前設置了'i = 1;',並且在運行循環之後將'b'看作'1x3675'。 –