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!

Answers (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 Comments

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.
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.
I do not know, sorry. Material I found earlier implied that in compiled code, the signal names are not available.
Thanks for your help. Maybe someone else finds a solution :)
Have a nice day!

Sign in to comment.

Products

Release

R2020b

Asked:

Tom
on 22 Jul 2022

Commented:

Tom
on 22 Jul 2022

Community Treasure Hunt

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

Start Hunting!