From: Jakob on
Hi, I would like to interpolate each row of Matrix Ai to Bi values, iterpolated through A and B.
It works with a loop. Is there a quicker way as the dataset is quite large and it takes ages.
Thx,
J.

Bi=zeros(n,m);
for i=1:n
Bi(i,:)=interp1(A(n,:),B(n,:),Ai(n,:));
end
From: kinor on
"Jakob " <jakob.abermann(a)uibk.ac.at> wrote in message <hldi6h$ioo$1(a)fred.mathworks.com>...
> Hi, I would like to interpolate each row of Matrix Ai to Bi values, iterpolated through A and B.
> It works with a loop. Is there a quicker way as the dataset is quite large and it takes ages.
> Thx,
> J.
>
> Bi=zeros(n,m);
> for i=1:n
> Bi(i,:)=interp1(A(n,:),B(n,:),Ai(n,:));
> end

Hi Jakob,

I guess the n in the loop should be replaced by i:
Bi=zeros(n,m);
for i=1:n
Bi(i,:)=interp1(A(i,:),B(i,:),Ai(i,:));
end

how large is the data set? Many calls of interp1 cause the parameter checking n-times.
to overcome this you two of many ideas:
1.) vectorize your data and use just one call
2.) use interp2 with linear interpolation, which produces no influence of neighbouring lines.
like:
y = meshgrid(1:size(Bi,1), 1:size(Bi,2))';
Bi = interp2(A, y, B, Ai, y);

hth
kinor