How to interpolate from a dataset using interp3?
Show older comments
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
Accepted Answer
More Answers (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
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!