How can I keep track of Handle Graphic objects in my MATLAB S-Function Block?

Technical Source
2 min readOct 9, 2021

I have a custom MATLAB S-Function block that is used to plot data while the simulation is running. How can I keep track of the handle graphic objects that are created while this block executes?

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

There are two main options that can be used to keep track of handle graphic objects:

1. Use tags and findobj.

This method works well if you will only ever need a single instance of the block in the model. If you may need multiple instances of the block in the model it may not work well as the value of the tag property is generally hard coded.

a. When the handle graphic object is created set the ‘tag’ property to a unique ID such ‘myLine’

b. In later block methods when the object needs to be used use findobj in order to get a handle to the object>> h = findobj(0,’tag’,’myLine’)

2. Use block UserData

This method works well if you may need multiple instances of the block in the model. This is because the block UserData is block instance specific, meaning that each instance of the block could easily have a reference to their own handle graphic object.

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.