Populating a 3D lookup table

조회 수: 15 (최근 30일)
Stephen
Stephen 2011년 8월 7일
I have a simple 3x512 array (x,y,z) in an ascii table file that is located in a directory.
I want to create Simulink lookup table that accepts values for y and z and returns the corresponding interpolated x value.
Is there a way that I can populate the lookup table with the contents of the array in the ascii file? Most examples I see involve manual entry of individual data triplets. I just want to load the file.
Thanks.

답변 (5개)

Image Analyst
Image Analyst 2011년 8월 7일
A 3 x 512 array is a 2D array, not a 3D array. Assuming you've read your ASCII table into an array in your program (perhaps using csvread or dlmread), you could do something like (untested)
[rows columns] = size(array3x512);
for row = 1 : rows
x = array3x512(row, 1);
y = array3x512(row, 2);
z = array3x512(row, 3);
lut2D(y, z) = x;
end
Then later, when you have some arbitrary y and z that you want the x for, you just say
x = lut2d(y,z);
Of course you'll have to round all your indexes to integers - that's required if you want to do a look up table instead of interpolation. You may also have to figure out what to do if every single y and z pair is not represented.

Stephen
Stephen 2011년 8월 7일
Thanks.
I'm sure your suggestion would work with a Matlab script, but I'm trying to use a Simulink lookup table.

Stephen
Stephen 2011년 8월 8일
I decided just to create a function. I used SFTools to curve fit the data and SFTool was able to provide a function that fitted too.

Richard Willey
Richard Willey 2011년 8월 8일
Hi Stephen
I did a webinar a couple years back focusing on using sftool to generate lookup tables for Simulink.
The webinar includes (what I hope is) some useful code that you can use to optimize the location of the break points for the resulting LUT.
You can download the code from MATLAB Central

Stephen
Stephen 2011년 8월 8일
Thanks Richard, I will watch your webinar

카테고리

Help CenterFile Exchange에서 Dictionaries에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by