How can I force the encoder to calculate both upstream branches of a switch?

1 次查看(过去 30 天)
I have a Simulink model that has a switch block that chooses to pass the output of lookup table "A" or the output of lookup table "B" based on a switch condition. In the C-Code that the encoder produces, it (logically) only calculates and passes the output from the table that is "selected" and does not determine the output from the other table. For purposes of data collection for debugging and analysis, I would like the outputs from both tables to be calculated all the time and then have the switch pass the selected value. What is the easiest way for me to force the encoder to generate code that will calculate the output from both tables all the time?
Simularily (and again, for debug and analysis purposes), I would like to know how to force the encoder to create "global" variables for any intermediate signal I would like to monitor. I have had some luck with just giving signals a specific name but I wanted to find out if there were any other ways.
Thank you!

回答(1 个)

Glen Tallarek
Glen Tallarek 2022-8-23
I think I found a way and it seems to work.
In the "Signal Properties" box and the "Logging and accessibility" tab for the table look-up output signals, I checked the "Test point" box. When I saved the model and then generated the code I got what I wanted -- each table output value was calculated and the values were stored to the RAM variables (that were created with the output signal names) and then the switch chose the appropriate value to pass.
I think I am all set. However, if anyone can confirm that this is the best method or can provide an alternative method, I would appreciate it. Thanks in advance!

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by