MATLAB Answers

0

Multiplication in cell arrays

Asked by Behzad Navidi on 12 Nov 2019 at 20:51
Latest activity Answered by David Hill on 12 Nov 2019 at 21:44
Hey all, I have a cell (408*1), which has 408 rows of 33*33 array inside it. I attached this cell to this question (the name is precip(my_data).mat).
now I want to multiply a 408*1 double array to this cell. I attached this array too (the name numbers.mat).
so please help me to do multiply my file (numbers.mat) to my data (precip.mat). In the end I would like to have:
precip(my_data) * (numbers.mat) %each row multiplying to the same row from numbers
Thank you all in advance.

  0 Comments

Sign in to comment.

2 Answers

Answer by David Hill on 12 Nov 2019 at 21:44
 Accepted Answer

Or a simple loop.
for i=1:408
PRECTOTCORR{i}=PRECTOTCORR{i}*result(i);
end

  0 Comments

Sign in to comment.


Matt J
Answer by Matt J
on 12 Nov 2019 at 21:37
Edited by Matt J
on 12 Nov 2019 at 21:38

result = cat(3,precip{:}).*reshape(numbers,1,1,[]);
There seems little reason either for precip to be a cell array or to turn the result back into one. But if you must,
result=num2cell(result,[1,2]);

  0 Comments

Sign in to comment.