Interpolate matrix in 4D

I have a matrix data of size 20,10,20,10.
It is a 3D object that changes across time (10 time points which represent 10 seconds)
I would like to create a smooth transition interpolating values to subdivide those 10 seconds into e.g., 10th of a second, so 100 time points in total.
How to go about this in Matlab?

Respuestas (1)

Matt J
Matt J el 8 de Mzo. de 2023

1 voto

You can use griddedInterpolant (preferable IMHO) or interpn.

3 comentarios

Matt J
Matt J el 8 de Mzo. de 2023
Editada: Matt J el 8 de Mzo. de 2023
You can also use imresizen from this FEX download,
A=rand(20,10,20,10);
Ainterp=imresizen(A,[1,1,1,10]);
whos A Ainterp
Name Size Bytes Class Attributes A 20x10x20x10 320000 double Ainterp 20x10x20x100 3200000 double
This doesn't subdivide the sample locations, though. It increases the fineness of the sampling without necessarily preserving the original samples.
Tahariet Sharon
Tahariet Sharon el 8 de Mzo. de 2023
Thanks. I don't understand this function. what does the [1,1,1,10] mean?
I want to preserve the values in A(:,:,:,1) and in A(:,:,:,10), which must be identical to the values in the Ainterp(:,:,:,1) and Ainterp(:,:,:,100). And the new values should be interpolated accordingly.
Matt J
Matt J el 8 de Mzo. de 2023
Editada: Matt J el 8 de Mzo. de 2023
what does the [1,1,1,10] mean?
It means make the 4th dimension 10 times bigger.
I want to preserve the values in A(:,:,:,1) and in A(:,:,:,10), which must be identical to the values in the Ainterp(:,:,:,1) and Ainterp(:,:,:,100). And the new values should be interpolated accordingly.
griddedInterpolant will do that.
A=rand(20,10,20,10);
F=griddedInterpolant(A);
Ainterp=F({1:20,1:10,1:20,linspace(1,10,100)});
whos A Ainterp
Name Size Bytes Class Attributes A 20x10x20x10 320000 double Ainterp 20x10x20x100 3200000 double

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 8 de Mzo. de 2023

Editada:

el 8 de Mzo. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by