How to interpolate from a dataset using interp3?
Afficher commentaires plus anciens
Hi,
I have a dataset (4-D complex double) of dimensions 32 x 31 x 21 x 6. The first three parameters 32x31x21 defines two frequencies and heading values, and together theat creates a force variation in 3D space. The last parameter (6) refers to the degrees of freedom. Now, I want to interpolate this data set for a given two frequencies and a heading angle value and obtain the correct complex force value. I have attached the sample dataset here (sampleData.mat), and I'd suppose a sample code would look like the following, but it's not working.
I haven't worked much with interp functions, so I really appreciate your help.
clear; clc;
load('sampleData.mat');
freq1 = 0.01; freq2 = 0.01; heading = 0.01; % Sample values. Simply used for demonstration.
for i = 1:6
x(i,:) = interp3(X, Y, Z, dataset(:,:,:,i), freq1, freq2, heading);
end
Réponse acceptée
Plus de réponses (1)
It's completely unlogical, but the documentation of interp3 says:
If X, Y, and Z are grid vectors, then size(V) = [length(Y) length(X) length(Z)]
where V corresponds to your 4d array "dataset".
So you will have to modify your code to:
clear; clc;
load('sampleData.mat');
freq1 = 0.01; freq2 = 0.01; heading = 0.01; % Sample values. Simply used for demonstration.
for i = 1:6
x(i,:) = interp3(X, Y, Z, permute(squeeze(dataset(:,:,:,i)),[2 1 3]), freq1, freq2, heading);
end
x
1 commentaire
Jake
le 29 Avr 2023
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!