Operator '.*' is not supported for operands of type 'cell'.

조회 수: 303 (최근 30일)
Gözde Üstün
Gözde Üstün 2020년 7월 9일
댓글: Image Analyst 2020년 7월 10일
Hello,
I am getting this error: Operator '.*' is not supported for operands of type 'cell'.
Here my code:
for a=1:m %d->m
for b=1:m %d->m
for x=1:m
for y=1:m
BO=BO+B(a,b,x,y).*(kron(A_ax(:,:,x,a),B_by(:,:,y,b))); %this is the Bell operator
end
end
end
end
And b is coming from other code. I am converting it:
B=T(:,:,:,:);
B=cell2mat(B);
I really dont understand why I have this error and how I can solve it

답변 (2개)

Matt J
Matt J 2020년 7월 9일
편집: Matt J 2020년 7월 9일
Well, you need to check whether B is a cell array or not (it almost certainly is). Did your call to cell2mat work?
  댓글 수: 3
Matt J
Matt J 2020년 7월 10일
Well, that explains everything. Multiplication with a cell array will not work
>> {2}.*3
Undefined operator '.*' for input arguments of type 'cell'.
Image Analyst
Image Analyst 2020년 7월 10일
Hopefully after you read the FAQ, you'll have a better idea of what a cell array is, how it works, and how to use it: FAQ : What is a cell array? And you'll learn when to use braces, when to use parentheses, and when to use brackets.

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


Image Analyst
Image Analyst 2020년 7월 9일
If B is a cell array, try B{a,b,x,y} instead of B(a,b,x,y) to get the contents of the cell.
  댓글 수: 1
Gözde Üstün
Gözde Üstün 2020년 7월 10일
B is a cell array because when I tried to convert it, I am getting this error:
Dimensions of arrays being concatenated are not consistent.
Error in cell2mat (line 118)
ct{mref{:}} = cat(cdim+1,c{mref{:},:});

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by