" Array dimensions must match for binary array op."

1 次查看(过去 30 天)
Dear experts,
I need your help;)
I got an Error :" Array dimensions must match for binary array op."
I have 1x14 cell ThAll : { 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double 4-D double}.
Each "4-D double" is a different size matrix . I need to find mean value matrix across all of these 4-D double matrices.
At first , I wanted to make all matrices in one ThAll cell array in the same size with NaN, then add all of them and find one mean value matrix across all matrices. I do it in next way:
for k = 1:length(ThAll) % Im not sure if Im making the same size for all matrices right; I think in this part is error
m = size(ThAll{k},1);
ThAll{k}(m+1, : , :, :) = NaN;
end
sum = ThAll{1}; % sum of all matrices
for i = 2:length(ThAll)
sum = sum + ThAll{i};
end
meanThAll = sum ./ length(ThAll); % one mean matrix across all matrices in cell array
Can someone help with this Error :" Array dimensions must match for binary array op" in my case ?
A lot thanks in advance!

回答(1 个)

Sulaymon Eshkabilov
Here is one of the easy solutions:
for jj=1:numel(ThAll)
TH_all=ThAll{jj};
for kk=1:4
TH_ALL(jj, kk)=mean2(TH_all(:,:,kk));
end
end
  4 个评论
IM
IM 2020-6-6
Hey Walter! Yes, the error "Brace indexing is not supported for variables of this type" occurring on TH_all=ThAll{jj};
After :
for jj=1:numel(ThAll)
TH_all=ThAll{jj};
for kk=1:4
TH_ALL(jj, kk)=mean2(TH_all(:,:,kk));
end
end
ThAll is no more 1x14 cell array . ThAll became simply "4-D double".
Walter Roberson
Walter Roberson 2020-6-6
That does not make sense unless it happened before the code you posted.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by