Method to get real time value from Lookup table in Simulink

2 次查看(过去 30 天)
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!

回答(1 个)

Ashutosh Bajpai
Ashutosh Bajpai 2023-2-17
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.

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by