I solved it. I copy here my solution in case it can help somebody:
%Convert a1 matrix to cell
[~,r]=size(a1);
a1c{1,n}=[];
for i= 1:r
a1_c{1,i}=a1(:,i);
end
% Delete repeated values
for i2=1:r
a1c{1,i2}=unique(a1c{1,i2}','stable')';
end
%Convert a2 matrix to cell
[~,r]=size(a2);
a2c{1,n}=[];
for i= 1:r
a2_c{1,i}=a2(:,i);
end
%Interpolate data
% b is the vector of values to be interpolated
Interp_data{1,r}=[];
for i3=1:r
Interp_data{1,i3}=interp1(a1c{1,i3},a2c{1,i3},b{i3})
end
b=cell2mat(Interp_data);
John