How to get input from a simulink model to .m file ?

2 ビュー (過去 30 日間)
PRERNA MALAVIYA
PRERNA MALAVIYA 2016 年 2 月 22 日
回答済み: Tejas 2024 年 8 月 16 日
I made a simulink model and linked it with interpreted matlab function block which has my .m code file, but I need 6 inputs to the .m file that are supposed to come from my model. What function do I use in my .m file to get values from my simulink model. As the interpreted function block has only one input, I have used a MUX.
  2 件のコメント
Sahib Ullah
Sahib Ullah 2020 年 4 月 14 日
if you have resloved your problem kindly update post your answer i am facing same problem
thanks
Aakash
Aakash 2024 年 8 月 15 日
did you find an answer to your question

サインインしてコメントする。

回答 (1 件)

Tejas
Tejas 2024 年 8 月 16 日
Hello Prerna,
The output of a 'MUX' is a vector, allowing the elements within the output signal to be indexed like any other vector elements. To demonstrate this, consider the following example: Six 'Constant'blocks are created and connected to a 'MUX'. The output from the 'MUX' is then directed to an 'Interpreted MATLAB Function Block'.
The 'Interpreted MATLAB Function Block' extracts each input and calculates their sum, which is then displayed in the 'Display' Block. Below is the code used within the 'Interpreted MATLAB Function Block'.
function output = mFileFromMATLAB(inputVector)
% Extract each input from the vector
input1 = inputVector(1);
input2 = inputVector(2);
input3 = inputVector(3);
input4 = inputVector(4);
input5 = inputVector(5);
input6 = inputVector(6);
output = input1 + input2 + input3 + input4 + input5 + input6;
end

カテゴリ

Help Center および File ExchangeInteractive Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by