Operator '.*' is not supported for operands of type 'cell'.
164 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (2)
Matt J
le 9 Juil 2020
Modifié(e) : Matt J
le 9 Juil 2020
Well, you need to check whether B is a cell array or not (it almost certainly is). Did your call to cell2mat work?
3 commentaires
Matt J
le 10 Juil 2020
Well, that explains everything. Multiplication with a cell array will not work
>> {2}.*3
Undefined operator '.*' for input arguments of type 'cell'.
Image Analyst
le 10 Juil 2020
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
le 9 Juil 2020
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.
See the FAQ: What_is_a_cell_array?
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!