array dimensions must match in binary op

I am trying to perform this code 3D data but I am getting this error " array dimensions must match in binary op". To solve this error can anybody help me please.
data_p=permute(data,[3,2,1]); % data
for kk=1:5 % outer loop
for m=1:niter % number of iteration
for i=1:1801
for j=1:10
for ii=2:k
D(i,:,j)=data(i,:,j)-C(:,:,j);
D=cumsum(sqrt(dot(D,D,1)));
if D(end)==0
C(:,ii:k,j)=data(:,ones(1,k-ii+1),j);
return
end
C(1:k,:,:)=data(find(rand<cumsum(D)./sum(D),3),:,:);
C_p=permute(C,[3,2,1]);
[~,L]=max(bsxfun(@minus,2.*real(C.*data_p),dot(C_p,C_p).'));
end
end
end
end
end
Error:
Array dimensions must match for binary array op.
Error in test5(line 51)
[~,L]=max(bsxfun(@minus,2.*real(C.*data_p),dot(C_p,C_p).'));

댓글 수: 4

What is size(C.*data_p) ? What is size(dot(C_p,C_p).') ?
When I look at that code, I would expect you to be using C_p.*data_p
AS
AS 2020년 9월 17일
C.*data_p for this error is showing
Array dimensions must match for binary array op.
The size of C is 3 by 3 by 10
size of C_p=10 by 3 by 3
data=1801 by 3 by 10
AS
AS 2020년 9월 17일
I have used C_p.*data_p this also as you mentioned, but same error is showing
When you multiply something whose dimensions are 3, 3, and 10, by something whose dimensions are 3, 10, and 1801, then what size of output are you hoping for? Something whose dimensions are 3, 3, 10, and 1801 -- a 4 dimensional result?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

AS
2020년 9월 17일

댓글:

2020년 9월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by