How to interpolate across 2D Matrix with 3 known parameters?

10 Ansichten (letzte 30 Tage)
Hello all, I will try to make this as clear as possible.
I've attached my .txt file but if you cannot see this, it looks like the screenshot below.
I have already imported the data into MATLAB using textscan where the x data is my desired variable, Velocity. So I showed the first three configurations but there are many more matricies. The way I have it imported in matlab is as a double type matrix with all that data like shown in the text file (not sure if this is the best way for what I'm trying to do)
The top left corner of the matrix shows the configuration. For example, each Velocity matrix has a different values for configuration 20, configuration 21, and configuration 22.... etc.
Each matrix has the left column side varying in position (0.00,0.01,....etc) and the top row varying in height (0,5,10,15)...
I hope I explained that well. Basically I am trying to interpolate across configuration, position, height, to find a new velocity ('x' values).
I am not even sure if it's possible to do this interpolation. For instance, I want to know the value of Velocity at configuration 20.5 (inbetween 20 and 21) at a known position .05 and known height 10. Is this possible?
configuration = [20,21,22...etc] (A simple vector of known values from data -- I grabbed this from the imported data.)
Position = [0.00 0.01 0.02....etc] (These are the same for all matricies).
Height = [0,5,10....etc] (These values are the same for all matricies.
I tried to use interpn vq = interpn(Position,Height,configuration,Velocity,0.05,10,21,'linear',-1). I am just confused on how I would do this across the different configuration or if its even possible?? Do I have to reformat how I stored the data?
Thanks so much for your time to read it!!

Akzeptierte Antwort

Matt J
Matt J am 29 Sep. 2020
Bearbeitet: Matt J am 29 Sep. 2020
I am just confused on how I would do this across the different configuration or if its even possible?
You interpolate between Configuration values just as you would interpolate between Position and Height, e.g.,
vq = interpn(Position,Height,Configuration,Velocity, 0.055,10.3,21.6, 'linear',-1)
There is nothing more special about the Configuration coordinate axis than the other coordinate axes.
  3 Kommentare
Matt J
Matt J am 29 Sep. 2020
Yes, the data you are interpolating must be in the form of a 3D array if you are interpolating in 3 dimensions.
Vickie Truong
Vickie Truong am 30 Sep. 2020
Thanks for your solution. So I have made a multidim array. It's 14x25x15. Where 15 is the dimension of the configuration. For example (:,:,1) is configuration 20, (:,:,2) is configuration 21. Then inside these are the 2d matricies where the column in height and the rows are position.
I used that function interpn and it works. The problem is I don't really understand how its working. Like how does the interpn function know if the rows are position or the columns are altitude when I only gave it a vector of my known position and altitude values? Like how does it know which dimension of matrix to go to? Is it because I 'set' position to be x which interpn determines x to rows? And I set altitude to y which interpn determines to be columns, etc?
vq = interpn(Position,Height,Configuration,Velocity, 0.055,10.3,21.6, 'linear',-1)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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!

Translated by