- https://www.mathworks.com/help/sps/powersys/ref/multimeter.html#:~:text=The%20power_compensated%20example%20uses%20a%20Multimeter%20block%20to%20measure%20the%20voltage%20across%20the%20secondary%20winding%20of%20a%20Saturable%20Transformer%20block%20and%20the%20currents%20flowing%20through%20two%20Series%20RLC%20Load%20blocks.
- https://www.mathworks.com/help/simulink/slref/toworkspace.html
如何不使用Multimeter模块通过脚本获取Simulink模块内部的测量数据?
조회 수: 6 (최근 30일)
이전 댓글 표시
我在Simulink中进行电力系统模拟时遇到了一个问题。在我的模型中,我有一个三相短路模块,该模块内部可以测量诸如短路电流之类的参数。通常,如果需要记录和分析测量数据,我们会在Simulink模型的信号线上手动点击右键选择“记录信号”。然而,我希望能够通过编写MATLAB脚本来自动化这一过程,并且我不想在模型中额外添加Multimeter模块来实现这一点。
请问有没有办法在不添加Multimeter模块的情况下,通过脚本直接访问和记录Simulink模块内部的这些测量数据?我知道这可能需要使用Simulink API和数据日志记录功能,但是不确定具体的实施步骤。如果有人能提供指导或相应的代码示例,将不胜感激。
谢谢大家!
댓글 수: 0
답변 (1개)
Yash
2024년 1월 12일
Hi 珊,
The following commands can be used to automate the processing of logging a signal without using the "Multimeter" block:
% open the Simulink model (using the example model "power_compensated" here)
open_system('power_compensated');
% Add a 'To Workspace' block to the Simulink model
toWorkspaceBlock = add_block('simulink/Sinks/To Workspace', 'power_compensated/To Workspace');
% Set the variable name for the signal to be logged and its save format
set_param(toWorkspaceBlock, 'VariableName', 'logged_signal');
set_param(toWorkspaceBlock, 'SaveFormat', 'Array');
% Connect the block with its port number to "To Workspace" block for the
% signal you want to log (Demux port number 1 signal in this case)
add_line('power_compensated', 'Demux/1', 'To Workspace/1');
% Run the simulation and the logged signal will be saved to the workspace
sim('power_compensated');
Refer here for more information on the "power_compensated" example model and “To Workspace” block:
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!