4D Table Interpolation
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fawad Farooq Ashraf
el 5 de Feb. de 2023
Comentada: Voss
el 5 de Feb. de 2023
I have a data set in four variables (alpha,beta,gamma,lambda).
Here alpha is a 10 element vector, beta is a 8 element vector, both gamma and lambda have four values each.
The data is given such that for each value of lambda, there are 4 tables, and those 4 tables correspond to each value of gamma. Each of those four tables is a 8x10 matrix whose rows correspond to values of beta and columns correspond to values of alpha.
I tried to implement it this way (sample code using random values):
alpha = 1:10;
beta = 1:8;
gamma = 1:4;
lambda = 1:4;
m = length(beta);
n = length(alpha);
Data(:,:,1,1) = rand(m,n); % alpha in first dimension, beta is 2nd dimension, gamma in 3rd and lambda in 4th
Data(:,:,2,1) = rand(m,n);
Data(:,:,3,1) = rand(m,n);
Data(:,:,4,1) = rand(m,n);
Data(:,:,1,2) = rand(m,n);
Data(:,:,2,2) = rand(m,n);
Data(:,:,3,2) = rand(m,n);
Data(:,:,4,2) = rand(m,n);
Data(:,:,1,3) = rand(m,n);
Data(:,:,2,3) = rand(m,n);
Data(:,:,3,3) = rand(m,n);
Data(:,:,4,3) = rand(m,n);
Data(:,:,1,4) = rand(m,n);
Data(:,:,2,4) = rand(m,n);
Data(:,:,3,4) = rand(m,n);
Data(:,:,4,4) = rand(m,n);
idat = interpn(alpha,beta,gamma,lambda,Data,1,2,3,4);
This code gives me errors. How can I resolve it? Do I need to create an n-dimensional grid? or am I making some mistake in the making of 4D tables.
0 comentarios
Respuesta aceptada
Voss
el 5 de Feb. de 2023
Editada: Voss
el 5 de Feb. de 2023
Swap your definitions of m and n (or equivalently use rand(n,m)). Like you said, alpha is 1st dimension, beta is 2nd.
alpha = 1:10;
beta = 1:8;
gamma = 1:4;
lambda = 1:4;
m = length(alpha);
n = length(beta);
Data(:,:,1,1) = rand(m,n); % alpha in first dimension, beta is 2nd dimension, gamma in 3rd and lambda in 4th
Data(:,:,2,1) = rand(m,n);
Data(:,:,3,1) = rand(m,n);
Data(:,:,4,1) = rand(m,n);
Data(:,:,1,2) = rand(m,n);
Data(:,:,2,2) = rand(m,n);
Data(:,:,3,2) = rand(m,n);
Data(:,:,4,2) = rand(m,n);
Data(:,:,1,3) = rand(m,n);
Data(:,:,2,3) = rand(m,n);
Data(:,:,3,3) = rand(m,n);
Data(:,:,4,3) = rand(m,n);
Data(:,:,1,4) = rand(m,n);
Data(:,:,2,4) = rand(m,n);
Data(:,:,3,4) = rand(m,n);
Data(:,:,4,4) = rand(m,n);
idat = interpn(alpha,beta,gamma,lambda,Data,1,2,3,4);
disp(idat)
Edit to show that the interpolated value matches the input table:
Data(1,2,3,4)
7 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!