Multiply two cell arrays
Show older comments
Hi i have following two cell arrays mul1 and mul2.
I want to multiply each cell of mul1 with corresponding cell of mul2. I am using following code
for i=8
for j=7
mul3{i,j}= mul1{i,j}.*mul2{i,j};
end
end
but it gives error:
Error using .*
Matrix dimensions must agree.
i also tried without using loop but still same issue.
Please help
3 Comments
Stephen23
on 28 Feb 2018
@lucksBi: your title and question are both incorrect: it is not possible to multiply cell arrays, and this is not what you are doing. What your code actually does is multiply some (presumably numeric) arrays that happen to be stored in the cells of a cell array. The error you are getting is because they have incompatible sizes, so please tell us what the sizes are when the error occurs:
size(mul1{i,j})
size(mul2{i,j})
lucksBi
on 28 Feb 2018
Stephen23
on 28 Feb 2018
lucksBi: I did not ask you for the size of mul1 or mul2. Please read my comment again.
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!