Interpolating multidimensional output and input
6 views (last 30 days)
Show older comments
Hi,
I have a function that uses a three-element vector as input and gives a two-element vector as output. From evaluating the function at a large number of three-element vectors, I have the the corresponding number of two-element outputs. Now I want to interpolate the inputs and outputs but I don't know how. I know that if the output was a single number per three-element vector, then I could use interpn, but in my case the output has two elements that are not independent of each other.
For example, one could have
Input = [0 0 0; 0 0 0.5; 0 0 1; 0 0.5 0; 0 0.5 0.5; 0 0.5 1;...
0 1 0; 0 1 0.5; 0 1 1; 0.5 0 0; 0.5 0 0.5;...
0.5 0 1; 0.5 0.5 0; 0.5 0.5 0.5; 0.5 0.5 1; 0.5 1 0; 0.5 1 0.5;...
0.5 1 1; 1 0 0; 1 0 0.5; 1 0 1; 1 0.5 0; 1 0.5 0.5; 1 0.5 1;...
1 1 0; 1 1 0.5; 1 1 1];
Output = rand(length(State),2);
% rand is just used for the example. In practice, this is
% Output = zeros(length(Input),2);
% for i=1:length(Input),
% Output(i,:) = function(Input(i,:));
% end
So, now I need to interpolate the output vectors for the interpolated input, but this has to be jointly for the two elements of the output vector. Any suggestions?
Thanks.
0 Comments
Answers (1)
Andrea Longobardi
on 22 Jul 2019
Hi, I've the same problem of yours. Did you find any solution? If yes, do you remember it? Thank you in advance.
4 Comments
Pai-Feng Teng
on 8 Mar 2021
Hello everyone. Please let me know if you find the answer too. I struggled with the same thing.
Walter Roberson
on 8 Mar 2021
Use separate interpolations.
For any one of the output elements, the value of the output is determined by the recorded data and the query point, and not by any of the other outputs. This is true even if the task were something like to find the nearest point on a 2D shape and return the x and y coordinates . (It is, of course, not true if you have a random component in choosing the output value.)
See Also
Categories
Find more on Interpolation 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!