Interpolation of 3D arrays against a 1D vector
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ahmad Gad
am 25 Aug. 2022
Kommentiert: Ahmad Gad
am 25 Aug. 2022
Hello all.
I have a video data represented as 3D matrix in the form of Data(x,y,t). Here, x,y represent the pixel number and t is the time. I have the time vector stored in a separate variable. I need to interpolate the variable Data at a new time vector represented by variable t_new to get the new variable Data_new(x,y,t_new). I am using the following code:
n = 20;
m = 60;
t = linspace(0,1,n)';
t_new = linspace(0,1,m)';
Data = rand(50,50,n);
Data_new = permute(interpn(t,permute(Data,[3 2 1]),t_new),[3 2 1]);
% Verification by plotting the time history of selected pixel:
x = 25;
y = 25;
plot(t,reshape(Data(x,y,:),n,1),t_new,reshape(Data_new(x,y,:),m,1))
It looks fine to me. but the main concerns I am asking about:
- I had to use permute twice. I am not able to do it without permute. Can I avoid this?
- Is there a faster method to perform this interpolation?
Thanks and best,
Ahmad
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!