How to dynamically generate a variable name based on the instance of a masked subsystem within a library block in Simulink?
5 次查看(过去 30 天)
显示 更早的评论
I tried to form a line model for my grid simulation and record some simulation results (current and power) at the same time. So this model is in my lib file. The easy way will be I take the recorded results into a bus output. And then when I initianize the instances in the simulink, I take a new bus element out node to save the results. But it will make the grid looks more caos because of so many nodes. I am thinking is it possible to
- Put a parameter in the mask for example "filename" and then let the "to workspace" block takes "filename" as the variable name
- Let model dynamically generate a variable name based on the instance in the simulink so it can filename1, filename2.. while I intiate the instances in the simulink.
The first method, I tried it, didn't work because the "to workspace" block takes "filename" not as a parameter but a constant string. So I want to know is it possible to realize what I want to do?
0 个评论
采纳的回答
Fangjun Jiang
2024-1-9
编辑:Fangjun Jiang
2024-1-10
That is right. Passing a string name through mask is difficult if not impossible.
But what you really need is to log signals and be able to uniquely identify them even though they are inside duplicated library instances. Time to use Simulink Data Inpsector (SDI), either manually or through API. Every block has its unique full path so do its signals.
2 个评论
Fangjun Jiang
2024-1-10
Take a look at SDI. It is a better way to log signal.
There is no need (or it shouldn't) to add blocks just for the need of signal logging.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!