3D interpolation on a table
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ruby pca
el 21 de Nov. de 2015
Respondida: Andrés Medina
el 26 de Abr. de 2020
Hello All,
I'm pretty new to matlab and I want to perform a 3D interpolation on a 70 x 7 matrix table. I've read the documentation for 3D but I don't seem to be able to apply it. Here is an example. For instance, if A = 0.33; B = 2.5, what will be the value of C at 75%? Thanks.
A B C
1% 25% 50% 75% 100%
0.30 2 1.1 1.5 1.0 0.3 0.8
0.30 3 1.6 1.8 1.0 0.5 0.8
0.30 4 1.3 1.1 1.0 0.8 0.8
0.30 5 1.2 1.1 1.0 0.6 0.7
0.30 6 1.3 1.1 1.0 0.8 0.7
0.30 7 1.3 1.2 1.0 0.8 0.7
0.30 8 1.3 1.1 1.0 0.8 0.7
0.30 9 1.3 1.1 1.0 0.8 0.7
0.30 10 1.3 1.1 1.0 0.8 0.7
0.30 11 1.8 1.3 1.0 0.8 0.7
0.35 2 1.3 1.8 1.0 0.9 0.1
0.35 3 1.6 1.9 1.0 0.9 0.8
0.35 4 1.4 1.2 1.0 0.9 0.8
0.35 5 1.2 1.1 1.0 0.8 0.8
0.35 6 1.4 1.2 1.0 0.8 0.7
0.35 7 1.3 1.1 1.0 0.8 0.7
0.35 8 1.2 1.1 1.0 0.8 0.7
0.35 9 1.3 1.5 1.0 0.8 0.7
0.35 10 1.9 1.4 1.0 0.8 0.7
0.35 11 1.3 1.1 1.0 0.8 0.8
0 comentarios
Respuesta aceptada
Andrei Bobrov
el 21 de Nov. de 2015
Editada: Andrei Bobrov
el 21 de Nov. de 2015
>> f = fopen('yourdata.txt');
cc = textscan(f,'%f %f %f %f %f %f %f ','HeaderLines',2,'CollectOutput',1 );
fclose(f);
g = cc{:};
[A,B,C] = ndgrid(unique(g(:,1)),unique(g(:,2)),[1 25 50 75 100]);
n = size(A);
V = permute(reshape(g(:,3:end),n([2,1,3])),[2,1,3]);
F = griddedInterpolant(A,B,C,V);
>> out = F(.35,4,1)
out =
1.4000
3 comentarios
Más respuestas (1)
Andrés Medina
el 26 de Abr. de 2020
First of all I want to thank Andrei for his invaluable contribution to the forum. Thanks for the example. Now my question goes. How can I do to be able to repeatedly interpolate with your code?. If I enter a value it works correctly. but not when I try to do it for many values, g in my case is a 5041x7 matrix.
Thanks a lot!!
theta_l=atan(abs(tan (deltal).*cos (gamma1))); %longitudinal angle, in rad
theta_t=atan(tan (deltal).*abs(sin (gamma1))) %transversal angle, in rad
%disp(['Angulo longitudinal = ', num2str(theta_l), ' Angulo transversal = ', num2str(theta_t)])
Z1 = theta_l;
Z11 = reshape(Z1,[1,8760]);
Z2= theta_t;
Z22 = reshape(Z2,[1,8760]);
f = fopen('concentracion_txt.txt');
cc = textscan(f,'%f %f %f %f %f %f %f ','HeaderLines',2,'CollectOutput',1 );
fclose(f);
g = cc{:};
[A,B,C] = ndgrid(unique(g(:,1)),unique(g(:,2)),[1 25 50 75 100]);
n = size(A);
V = permute(reshape(g(:,3:end),n([2,1,3])),[2,1,3]);
F = griddedInterpolant(A,B,C,V);
concentracion = F(Z11,Z22,1)
0 comentarios
Ver también
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!