Method to get real time value from Lookup table in Simulink

2 visualizzazioni (ultimi 30 giorni)
Hello, I want to make an model using matlab function block in Simulink which reflects real time value from Lookup table as the result of the matlab function block changes. The result of matlab function block is the input of the Lookup table. Would there be a method to realize that? Thanks!

Risposte (1)

Ashutosh Bajpai
Ashutosh Bajpai il 17 Feb 2023
You can use a MATLAB Function block in Simulink to reflect the real-time value from a lookup table as the result of the block changes. To do this, you can use the interp1 function in MATLAB to perform the lookup operation and return the result as the output of the function block. You can then use this output as the input to the lookup table. An example of this implementation would look like the following code:
function y = myFunction(u)
table = [0 1; 2 3; 4 5]; % Define your lookup table
y = interp1(table(:,1), table(:,2), u); % Perform the lookup
end
In this code, "u" is the input to the function block and "y" is the output, which is passed to the lookup table. You can then use this code in a MATLAB Function block in Simulink, and connect the input and output ports as needed.

Categorie

Scopri di più su Modeling in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by