how to implement lookup table in matlab code

how to implement lookup table in matlab code

3 Commenti

What type of "key" do you need?
Mustafa Sabah's "Answer" moved here:
Any type ,please
Cedric
Cedric il 4 Nov 2017
Modificato: Cedric il 4 Nov 2017
But you does "any" mean? Will you have numeric keys only, strings/char keys only, arrays of numbers, various objects, or a mix of any of these types/classes as keys?

Accedi per commentare.

Risposte (1)

It's puzzling that you're even asking the question. Maybe you have a strange definition of a look-up-table. In any language, a look-up-table is just an array of whatever things you want to look up. Therefore, in matlab, a lut is simply your standard array if whatever it is to store in your table is homogeneous and scalar, and a cell array otherwise.
%lut of 60 numbers
lut = randi(100, 1, 60);
value = lut(10); %get lut value corresponding to index 10
%lut of char arrays:
lut = {'the', 'quick', 'brown', 'fox', 'jumps', 'over', 'the', 'lazy', 'dog'}
value = lut(7); %get lut value corresponding to index 7

Categorie

Scopri di più su Operators and Elementary Operations in Centro assistenza e File Exchange

Richiesto:

il 26 Ott 2017

Risposto:

il 4 Nov 2017

Community Treasure Hunt

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

Start Hunting!

Translated by