MATLAB: How to multiply values in a cell by a vector

cell arrays

If I have a cell containing vectors, How can I multiply each cell with another vector?
Say cell C has a size of 10*2 and each element in cell C has a size of 100*175. I want to multiply each element in cell C with a vector d with a size 100*175(element by element multiplication).
I have tried
result=cellfun(@(n) n.*d,C,'UniformOutput',false);
But it matlab gives me this error
Error using .*
Matrix dimensions must agree.
Where did I do wrong? cheers

Best Answer

Where did I go wrong?
Despite your statement, at least one of the matrix or vector in your cell array does not have the same size as d. You can find out which one(s) with:
find(cellfun(@(n) ~isequal(size(n), size(d)), C))
Note that a matrix of size 100x175 is not a vector. A vector is a matrix whose all dimensions but one are 1. However, this is irrelevant to your problem, if all matrices in your cell array are the same size as your d, the code you wrote will work.