How to interpolate 2d data with constant spacing?

2 visualizaciones (últimos 30 días)
Sebastian
Sebastian el 4 de Dic. de 2017
Comentada: Sebastian el 5 de Dic. de 2017
I try to figure out a way to linear interpolate my data. i am not quite sure how to tell him that for each step it should add the 10 new values at the end of the vector _lin. There is probably a faster way to do this but i am really lost and on the verge of a mentally breakdown since i cant figure out these kind of "simple" tasks. If anyone has an idea for an approach on how to manage this linear interpolation over the entire profil with constant spaceing i would be very grateful. i tried a little with the interp1 but i guess you also have to make a loop for over each data point.
if true
vz=[ 1.5000e+003 1.5397e+003 1.5577e+003 ;
0.0000e+000 2.0862e+001 1.0443e+002 ]
n=3
for i=1:n-1
v_lin=linspace(vz(1,i),vz(1,i+1),10); % It would be also great if one could interpolate the entire plot
v_lin=[v_lin v_lin(i)]; % Here i want the interpolated data to just add for each loop
z_lin=linspace(vz(2,i),vz(2,i+1),10);
z_lin=[z_lin z_lin(i)];
end
  1 comentario
Sebastian
Sebastian el 5 de Dic. de 2017
so now i got this far, which is kinda ok. is there a way to interpolate with interp2 so that the one row gets constant spacing. where the vz(2,:) is suposed to be interpolated to zz=1:1:zmax and the vz(1,:) gets interpolated. i also tried with the mashgrid input and entering the form vz3 = interp2 (X, Y, Z, XI, YI).
if true
for i=1:n+1; %i added an extra end point by hand
v_lin(i,:)=linspace(vz(1,i),vz(1,i+1),int);
z_lin(i,:)=linspace(vz(2,i),vz(2,i+1),int);
end
v_lin2=[];
z_lin2=[];
for k=1:n+1
y=v_lin(k,:).';
p=z_lin(k,:).';
v_lin2=vertcat(v_lin2,y);
z_lin2=vertcat(z_lin2,p);
end
v_lin2=v_lin2';
z_lin2=z_lin2';
vz2=[v_lin2 ; z_lin2]
end

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by