MATLAB: Interpolate data in cell array

cell arrayfor loopinterp1interpolationMATLAB

I have 2 cell arrays both 5×1 cell. The first cell array contains A=40×1 double and the second B=40×11. Data in A{1,1} is related to B{1,1}. What I would like to do is use the function interp1 on each array of A and interpolate the corresponding data in B in the same manner. I have used the following code with no error before the data was contained in an array (I should say I need to repeat the interpolate on each of 11 columns of cell array B):
angle = (0:3:360)';
a = data(:,1);
b(:,1)=[];
b = interp1(a,b,angle);
My initial thought is to somehow use a for loop to go through each array and repeat the function, however I am unsure how to use the function on data presented this way.
Thanks, Jess

Best Answer

Possibly, this will do what you want:
%A and B: cell arrays of matrices. Must have the same size
%Matrices in corresponding cells in A and B must have the same number of rows
angle = (0:3:360)';
newb = cellfun(@(a,b) interp1(a, b(:, 2:end)), angle), A, B, 'UniformOutput', false);
I'm simply using cellfun to iterate over all the cells of A and B simultaneously. cellfun calls an anonymous function which is just a rewording of the code you've provided.