Populating a 3D lookup table
17 次查看(过去 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!