Populating a 3D lookup table
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (5)
Image Analyst
am 7 Aug. 2011
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 Kommentare
Richard Willey
am 8 Aug. 2011
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 Kommentare
Siehe auch
Kategorien
Mehr zu Dictionaries finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!