Interpolation for n-dimensional array data
25 views (last 30 days)
Hello, I have this function in which I calculate Uvals,Svals and Vvals and store them in array. In this case I have 4D data. I have attached the .mat file.
[Uvals(:,:,j,i),Svals(:,:,j,i),Vvals(:,:,j,i)]= svd(pro(rho1,rho2)); % two 'for' loops for 2 parameters 'rho1' and 'rho2' How to automate this for 'n' parameters?
I would like to retrieve entries of Uvals, Svals and Vvals like function of 2 variables 'rho1' and 'rho2'.
U = @(rho1,rho2) Uvals(...);
S= @(rho1,rho2) Svals(...);
V= @(rho1,rho2) Vvals(...);
Should I be using 'interp2' function for this? If have n-dimensional data, how can i make use of 'interpn' in my code? I had previously asked question in this context(https://de.mathworks.com/matlabcentral/answers/497657-accessing-function-output-for-different-values-of-variable?s_tid=prof_contriblnk), but I seek your help again. Thank you.
Christine Tobler on 22 Jan 2020
I don't think interpn would work very well for you: The U, S and V matrices returned by SVD are not linearly dependent on the input matrix to SVD, so linearly interpolating U, S, and V based on some grid points will not give the U, S and V of the matrix for a given set of points rho1 and rho2.
I think the only reliable way to do this is to just call svd(pro(rho1, rho2)) inside of those function handles.
What's the background for wanting to compute the SVD on some grid of rho1 and rho2 ahead of time? Is this to reduce computation time in the three function handles? If you can give some information about how you're planning to use those function handles, that would be helpful. For example: Do you always call all three of them? Do you call them many times for values rho1 and rho2 that are on grid points? For scattered values of rho1 and rho2?