- 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.
How to display Chart diagram in a report, using report generator?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (1)
Abhas
am 6 Aug. 2024
Hi Tommaso,
To visualize only the top-level diagram of a chart in Simulink, you may refer to the below steps:
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 Kommentare
Abhas
am 7 Aug. 2024
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.
Siehe auch
Kategorien
Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!