How to get the name of the input signal in a matlab function (simulink block)

Dear community,
i wondering if there is a way to get the name of the input signal of a "matlab function"-block.
That´s what my model looks like:
I already tried the get_param(u,...) to get the signal name but it didn´t work as the following error occurs: "Function 'get_param' not supported for code generation."
Is there any way to solve this?
Thanks for your help!

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 7 月 22 日
編集済み: Walter Roberson 2022 年 7 月 22 日

1 投票

If you are still trying to do that testing about nan, remember that code cannot do dynamic fieldname access in generated code; https://www.mathworks.com/matlabcentral/answers/506792-is-it-possible-to-access-struct-fields-dynamically-in-generated-code#answer_416689
so even if you can get the signal names in generated code, you cannot loop over the names in generated code to test the bus elements by name.

4 件のコメント

Tom
Tom 2022 年 7 月 22 日
I am still trying, yes, i know that i cannot loop over the names dynamically. I accepted that and that´s not what I want here.
Atm i only want to figure out the name of the 1 signal that enters my matlab function to at least be able to name the bus signal as soon as i find a NaN somewhere in it.
Is there a way to get the name of it?
So in this example all i want is to print out the signal name in my matlab function, it should look somehow like following:
signalname = ... %here comes the function for getting the signal name, if it is possible
disp(signalname)
This should give me "Bus1" (the signal name in my example) as an output.
Tom
Tom 2022 年 7 月 22 日
Maybe a possible workaround would be to get the name by using another simulink block. I am not quite experienced with these and the library is very large. But what i mean is something like that:
instead of the unspecified system a block that reads the signal name and puts it out is needed.
I hope you understand what i am thinking. If not, i can clarify it.
I am free for all solutions provided!
Thanks.
Walter Roberson
Walter Roberson 2022 年 7 月 22 日
I do not know, sorry. Material I found earlier implied that in compiled code, the signal names are not available.
Tom
Tom 2022 年 7 月 22 日
Thanks for your help. Maybe someone else finds a solution :)
Have a nice day!

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

カテゴリ

製品

リリース

R2020b

質問済み:

Tom
2022 年 7 月 22 日

コメント済み:

Tom
2022 年 7 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by