Simulink equivalent of inputname () or genvarname() for logging

3 ビュー (過去 30 日間)
Dimitri
Dimitri 2023 年 12 月 14 日
コメント済み: Dimitri 2023 年 12 月 14 日
Hello!
I would like to know if I can find an equivalent of MATLAB function inputname() or genvarname() for using in Simulink block.
Actually, I get an error
Function 'inputname' not supported for code generation.
I used a MATLAB block with code
function out = getVarName(var)
out = inputname(1);
end
In fact, this function I need for logging/debugging on ARM-target (using Simulink coder), so I don't want to change variables to structures.
By the way, could you please recomend me logging techniques for Simulink coder?
Thanks in advance!
  2 件のコメント
madhan ravi
madhan ravi 2023 年 12 月 14 日
Could you please tell the use case of using inputname() for this purpose?
Dimitri
Dimitri 2023 年 12 月 14 日
Yes, for exemple, I need to know the value of boolean variable, that represent of state of specific component (true --> Ready, false --> off). I have a numerous of this variables and I want, in ideal, have a file with: (example)
[time] | variable name | variable state
8746 bSensor1 True
8747 bMoover5 Falsa
Of course, I can manualy create a string constant, but I have quite a lot of flags and I like to do it in the simpliest way. Maybe my solutuon to use inputname() has no sense and I need to generate blocks automaticaly or etc

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

採用された回答

Fangjun Jiang
Fangjun Jiang 2023 年 12 月 14 日
編集済み: Fangjun Jiang 2023 年 12 月 14 日
Not sure if you are aware, the MATLAB Function block is typically executed at every simulation step. So even if inputname() and genvarname() worked, you would give it a name at every simulation step?? Of course, there are ways to make it run only once per simulation, but that is not how it is typically done to log or debug signal data.
To log a signal, select the signal line, right click, select "Properties" and fill the dialog. This has to be done pre-simulation. It can't be done while the simulation is running. This is for simulation. For data logging in a real-time target, see
web(fullfile(docroot, 'slrealtime/ug/signal-logging.html'))
  1 件のコメント
Dimitri
Dimitri 2023 年 12 月 14 日
Super! That's what I was I was searching for! Thanks a lot!

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

その他の回答 (0 件)

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by