How to display Chart diagram in a report, using report generator?
이전 댓글 표시
Hi,
I have a problem with the visualization of Chart diagram and related properties in my model.
I using this code line (in a matlab script) to search all the subsystem object (including chart):
allsubsysObj = modelObj.find('-isa','Simulink.SubSystem','-or','-isa','Simulink.ModelReference','-depth',1);
The script find the number of element that i'm expected (2 chart and 2 subsytem) but when i tried to put the diagram figure i obtained the inner content of the subsytem and the chart.
auxpara = CenterDiagram(Diagram(allsubsysObj(1)),R);
Cap = Text(strcat("Figure ",num2str(ChCounter),".",num2str(FigCounter),": ",allsubsysObj(1).Name," subsystem"));
Cap.Style = [{FontSize(Str.CapFontSize)},{Color(Str.CapColor)},{Bold(true)},{HAlign(Str.CapAlign)}];
FigCounter = FigCounter + 1;
subsec.add(auxpara);
subsec.add(Cap);
subsec.add(LineBreak());
How i can insert only the top level diagram of the chart?
답변 (1개)
Abhas
2024년 8월 6일
Hi Tommaso,
To visualize only the top-level diagram of a chart in Simulink, you may refer to the below steps:
- Use the "get_param" function to retrieve the handle of the chart or subsystem you want to visualize.
- Set the "ShowPortLabels" parameter to 'none' to hide the inner contents.
- Use the "Simulink.BlockDiagram.createSubsystem" function to capture the diagram as an image.
- Insert the captured image into your report.
The following is a sample example to demonstrate the same:
% Get the handle of the chart or subsystem
% Replace 'model_name/Chart' with the actual path to your chart or subsystem
chartHandle = get_param('model_name/Chart', 'Handle');
% Set to show no port labels, which hides inner contents for visualization
set_param(chartHandle, 'ShowPortLabels', 'none');
% Capture the diagram as an image
Simulink.BlockDiagram.createSubsystem(chartHandle);
% Now you can use the captured image in your report
You may refer to the following MathWorks documentation links to have a better understanding of the same:
댓글 수: 3
Tommaso
2024년 8월 6일
Abhas
2024년 8월 7일
Hi,
Ensure that the model is loaded before trying to access its components. Use the "load_system" function if necessary. Additionally, when using "get_param" to retrieve the handle, ensure that the full path to the chart or subsystem is correct. It should be the path within the Simulink model, not just the name.
Tommaso
2024년 8월 8일
카테고리
도움말 센터 및 File Exchange에서 Results, Reporting, and Test File Management에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
