Importing data to a 2-D Lookup Table Simulink
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a 245x3 matrix where the first column represents the x values, the second column represents the y values, and the third column represents the z values (attaching data set below). My end goal is to interpolate this data using a 2-D Lookup Table in Simulink to get all the z values that exist in the range defined by the x and y values. I have used the unique function on the x and y values to define my breakpoints, but I am struggling on what to input for the table data. If I just input the column vector that contains the z values for table data, the output is only one dimensional. How can I use the information I have to create a 2D matrix of the z values that correlate to the x and y values?
I have tried to find good examples that are similiar to my case to no avail. Any help is greatly appreciated!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1574027/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1574032/image.png)
2 comentarios
Respuestas (1)
Fangjun Jiang
el 21 de Dic. de 2023
Editada: Fangjun Jiang
el 21 de Dic. de 2023
The data is not in the right shape to do this.
- There are too many duplicated (x,y) pairs. For the dupicated (x,y) pairs, the z values are significantly different. You have to decide which z value to represent for a particular (x,y) pair.
- After unique([x,y],'rows'), there are only 25 rows of data
- Yet, there are 25 unique values for x and 25 unique values for y
- To fill a 2-D lookup table for 25 values of x and 25 values of y, you need 25x25=625 z values.
- Think of a 2-D lookup table as an Excel sheet, first column is all the x values, first row is all the y values. The rest squre cells are filled with the z values.
- As long as you can fill or generate data for those squre cells. You can use the Simulink 2-D lookup table. Click the "Help" on the dialog to bring up the document and examples.
- Your plot is also not right. The unique (x,y) pairs all have the same values for x and y, like (-62,-62), (62, 62). So the points should be shown alone the diagnal line of the x-y plane.
- But fundenmentally, you need to fill more data for the x from -62 to 62, and y from -62 to 62 grids.
2 comentarios
Fangjun Jiang
el 21 de Dic. de 2023
Yes, if you want to look up 25 values for x and 25 values for y.
Remember it is as if you lookup data on a paper. You find the row first, and then the column, and you find the value for that corresponding row and column.
Since you have the same grid value for x and y, you need to pay attention how the z values are arranged in rows and columns. I suggest you trying a simple example for x=[1 2 3] and y=[10 20] first if you never used the 2-D lookup table before.
Ver también
Categorías
Más información sobre Nonlinearity en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!