1

I have a complex Simulink model and want to generate in a subsystem one simple error message signal out of a lot of incoming error observing signals. These incoming signals are organised in a bus and are always 0, exept when an error occurs: then there is an edge to value. The error message should contain an individual bit code which is defined for every error name and error value in an excel list.

How can I assign this error code to a specific error signal with rising edge? I need something like a lookup function:

for (every signal):

if signal has edge to value,
look in list to signal name and output its error code.

My idea was to use a MATLAB function block with a bus input and a one-dimensional output. A .mat file generated before Simulation start contains a struct with the list inputs from the excel file and should be used as a parameter in the MATLAB function.

This solution seems a bit difficult though, since dynamic field referencing and interating through a structure is not supported for code generation. I cannot even get the signal name from the struct because the fieldnames function is not supported, too.

I am now wondering if there is another approach or the MATLAB function is still doable for my problem. Can I generate the code for the MATLAB function block in a PreLoadfcn? Does a S-function make sense here? Or is there even a Simulink based solution which does the Signal conversion?

f562
  • 21
  • 2

0 Answers0