How do I create a multi-dimensional array from a 2D data matrix?

2 views (last 30 days)
Hello all. I apologize in advance for any confusion in my question. This problem has so thoroughly confused me I'm not sure I can even explain it concisely.
Essentially, I need to create an N-dimensional array to hold output data for N input arguments. The goal is to interpolate across the inputs of the array to find desired data points.
So, for example, I have a 2D matrix of the following data points:
Input1 Input2 … InputN Output1 Output2 … OutputX
Input1 Input2 … InputN Output1 Output2 … OutputX
Input1 Input2 … InputN Output1 Output2 … OutputX
I'm looking for an efficient way to interpolate through this data and determine all the outputs for any input variation. I had though the best way to do this would be an N-dimensional matrix but now I'm not so sure.
Another problem is that the inputs are not guaranteed to be "square". For example, at a fixed Input1 value there might be 3 Input2 values, however at the next Input1 there may be only 2 Input2's.
Please let me know what additional information I can provide

Answers (1)

Ryan
Ryan on 19 May 2014
In case anybody is wondering, I solved it. My basic method was as follows:
  1. Determine how many elements were in each dimensions
  2. Create an empty array with the correct number of dimensions and elements
  3. Linearly index through the empty array. At each point, convert the linear index into subscript indices and then evaluate the input vectors to determine if there was a valid piece of data at that point. If so, place the data in the matrix.
  4. Then, I came back, looping through again, interpolating between existing data pieces to fill in the gaps.
It's not perfect but it works. It all depends on how your data is set up.

Categories

Find more on Multidimensional 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!