[英]matlab error using CAT, Dimensions of matrices being concatenated are not consistent
[英]How do i handle “Error using vertcat Dimensions of matrices being concatenated are not consistent” in Matlab?
所以我想連接mxn
矩陣以獲得1 x mn
矩陣。 我想連接的矩陣是從while循環生成的。 雖然列數總是3
,但我無法確定每次迭代會有多少行。 此外,每次迭代的行大小可能並不總是相同。
代碼在行大小都等於6
情況下運行,但是在它們不相等的情況下我得到一個錯誤:
使用vertcat時出錯連接矩陣的維數不一致。
部分代碼如下:
A = [];
B = [];
searchArea = 2;
for ii = 1: numel(velocity)
Do ....
while area(ii,:) < searchArea
Do ....
% COLLATE vectors for A
A = [A; [Ax(ii), Ay(ii), Az(ii)]];
Do ...
end
%# Copy the A into new variable (B) and Reshape into row vector so as to associate each row to its corresponding velocity
B = [B; reshape(A.',1,[])];
A = [];
end
有人可以告訴我這里我做錯了什么。 如果有需要,我會進一步澄清。 多謝你們!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.