Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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]

Respuestas (1)

Image Analyst
Image Analyst el 13 de Mayo de 2020
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 comentarios
Image Analyst
Image Analyst el 14 de Mayo de 2020
You can do this:
B=[1;1]
C=[2;2]
D=[3;3]
A = [B, C, D]
B =
1
1
C =
2
2
D =
3
3
A =
1 2 3
1 2 3
Geraldine Ejimadu
Geraldine Ejimadu el 14 de Mayo de 2020
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by