I have code segment that’s slowing my script down which I suspect should be possible to vectorize or speed up in some way. I want to use mldivide and calculate:
C = A \ B;
Where A is 27×27 matrix and B is a cell array with 1000 cells where each cell has size (27 x 6588) .
I want to do the calculation for each cell in B with the same A that never changes. At the moment I’m doing this in a loop like this:
for i=1:length(B)C = A \ B{i}; %doing the calculation on one cell in B
%Doing things with C here
end %moving on to the next one
But this means doing the calculation a thousand times in a loop. Isn’t there any quicker way of calculating C for all cells in B outside of the loop? I suspect cellfun could be a function that is suitable for something like this but I haven’t figured out how to get it to work.
Any suggestions on how to calculate this without the loop?
Best Answer