How to modify the sltrace.Graph objects? I want to delete an element of the DstBlocks array

2 views (last 30 days)
Hello dear Community,
I would like to delete a block from the DstBlock path. I am using sltrace function and the resulting sltrace.Graph is to be by the user modified. I have read that you have to use "set" and "get" methods because they are property values but I have not been succesful to modify anything. From Matlab help I see that set function can be used like this: set(object, property, value)
I am programming the following line to modify the Trace Path in this case I want to modify the Destination Blocks ( DstBlocks array):
test1 = sltrace(element, 'Destination', 'TraceAll','on');
set(test1.DstBlocks(1), "Value", [ ]);
I am trying here to delete/ modify the value of the first (1) object of the resulting array DstBlock of the resulting Trace Path (test1). What woudl be the correct function to use or the correct sintax if the function set is to be used? Thank you.

Answers (1)

Poorna
Poorna on 21 Apr 2024
Hi Jose Manuel,
I see you want to delete the 'DstBlocks(1)' of 'test1' which is an ouptut of the "sltrace" function. It is to be noted that "sltrace" is an analysis function, which means it is to analyze the signal paths of the model but not a modification tool to modify the signals/connections/blocks within the model. As mentioned in the official documentation of the "sltrace.graph" object, you can use the "sltrace.graph" object to do the following:
  • Highlight the signal path in the model.
  • Highlight any block in the model, including blocks that are not on the signal path.
  • Create a directed graph plot of the signal path.
If you instead want to modify the simulink model programmatically by adding/deleting lines, blocks etc. You can refer to the following documentation which lists the functions available to programmatically modify a simulink model:
To know more about the "sltrace" funtion, refer to the following documentation:
Hope this Helps!
  2 Comments
José Manuel
José Manuel on 22 Apr 2024
Many thanks Poorna,
I thought that there was a way to update the diagram programatically, but I don´t see any direct function to do that. However, you can do it manually by starting the trace path with the following help from matlab:
"... To display the complete path, press Ctrl+D to update the diagram. "
This means it is possible to somehow update the diagram, and so the result from the sltrace function. I mean the sltrace.Graph. object.
There is an example in the following link to hilight in red color a Scope and this is done proggrammatically.
highlight(x2Sources,[scopeHandle scopeIn1 scopeIn2])
where:
scopeIn1 = scopePorts.Inport(1);
scopeIn1 = get_param(scopeIn1,"Line");
scopeIn2 = scopePorts.Inport(2);
scopeIn2 = get_param(scopeIn2,"Line");
In conclusion, there is a way to work this around by adding elements in the highlight function. But what if the user wants to instead of adding new elements, wants to substract elements or make a some modifications to the highlighted path elements when the sltrace has been started programatically. Is there a way to modify the information saved in the x2Sources.TraceGraph that appears in this example, in which the user does not want some of the original path but wants to deactivate/delete/modify the highlighted path in a programatically way, without modifying the simulink model itself. I hope my words are not further confusing. Any more questions/answers are more than welcome.
José Manuel
José Manuel on 22 Apr 2024
Edited: José Manuel on 22 Apr 2024
I see that the Ctrl +D will only updates the model itself but not the trace path objects. Sorry, I have that misunderstood. However, in the x2Sources example where the Scope is added in the highlight function, is there a way to remove/modify elements from the inside of x2Sources array. Thank you for your support.

Sign in to comment.

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!