How to fix a matrix?Dimensions of arrays being concatenated are not consistent

1 次查看(过去 30 天)
I have a problem with the matrix dimension in my code:
I just want to calculate the average at the end of the code. This code actually works with the all the matrices(a big table of double) I have used before. However now I am struggling with this one table called UgisM0L06, that I will also upload. I dont understand how can I fix the fact that the matrix "L_PeaksM0L06 ", resulting from the last FOR LOOP ,does not give the same number of elements for each column.
I will upload also the table of doubles UgisM0L06.
Please, any help would be appreciated. let me know if something is not cler.
CODE:
% Shoes UgisM0L06
L_3=UgisM0L06(:,1:99);
% D_18(1:15,32)=[0];
mask = sum(L_3, 2)~=0;
comps = bwconncomp(mask);
compMaskList = comps.PixelIdxList; %chunks positions(steps rows)
L_3_components = cell(numel(compMaskList), 1);
for i=1:numel(compMaskList)
step{i} = L_3(compMaskList{i}, :);
if size(step{i})<=[30 99]
step{i}=[];
end
end
n_steps=step(~cellfun('isempty',step));
% n_steps=[step(1:2),step(8:10),step(13:19)];
if length(n_steps)>=12
steps=n_steps(1:12);
size(steps)
end
for i=1:length(n_steps)
Big_ToeM0L06{i}=[n_steps{i}(:,[83:84]),n_steps{i}(:,[90:91]),n_steps{i}(:,96)];
Peak_HalluxM0L06(i) = max(Big_ToeM0L06{i}, [], 'all');
Other_ToesM0L06{i}=[n_steps{i}(:,[81:82]),n_steps{i}(:,[85:89]),n_steps{i}(:,[92:95]),n_steps{i}(:,[97:99])];
Peak_PhalangesM0L06(i)=max(Other_ToesM0L06{i}, [], 'all');
MedFM0L06{i}=[n_steps{i}(:,[62:63]),n_steps{i}(:,[69:70]),n_steps{i}(:,[76:77])];
Peak_Mtpj1M0L06(i)=max(MedFM0L06{i}, [], 'all');
C_FM0L06{i}=[n_steps{i}(:,[64:66]),n_steps{i}(:,[71:73]),n_steps{i}(:,[78:80])];
Peak_Mtpj23M0L06(i)=max(C_FM0L06{i}, [], 'all');
LatFM0L06{i}=[n_steps{i}(:,[60:61]),n_steps{i}(:,[67:68]),n_steps{i}(:,[74:75])];
Peak_Mtpj45M0L06(i)=max(LatFM0L06{i}, [], 'all')
end
L_PeaksM0L06=[Peak_HalluxM0L06',Peak_PhalangesM0L06',Peak_Mtpj1M0L06',Peak_Mtpj23M0L06',Peak_Mtpj45M0L06'];
for j=1:5
AverageM0L06(j) =mean(L_PeaksM0L06(:,j));
end
AveragesM0L06=[AverageM0L06]

回答(1 个)

Image Analyst
Image Analyst 2020-5-13
I didn't run your code but usually "Dimensions of arrays being concatenated are not consistent" means that you are stitching/concatenating things of different sizes. For example, you are
  1. Vertically concatenating matrices with different numbers of rows, or
  2. Horizontally concatenating matrices with different numbers of columns.
Example for case 1
1 2
3 4
cannot be concatenated with
1 2 3
3 4 5
because column 3 cannot be blank in rows 1 and 2.
Which is your situation?
  3 个评论
Geraldine Ejimadu
Geraldine Ejimadu 2020-5-14
I understand what you say. I think the last FOR LOOP in my code is already doing it, but for this particular matrix that I have to use (UgisM0L06), it is not working. I have used more that twenty large matrixes, and they work, except for this one.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by