Populating a 3D lookup table
조회 수: 15 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (5개)
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.
댓글 수: 0
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.
The webinar is available at: <http://www.mathworks.com/company/events/webinars/wbnr40143.html?id=40143&p1=525984714&p2=525984732>
You can download the code from MATLAB Central
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Dictionaries에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!