MATLAB Answers

Add a variable in eventdata

3 views (last 30 days)
Saurav Roy
Saurav Roy on 28 Apr 2020
Commented: Saurav Roy on 28 Apr 2020
I need to add a variable that is user defined into 'eventdata' that is being generated using a GUI that I have made.
eventdata consists of Source and EventName.
I want to add another variable 'tag' such that now
eventdata consists of Source, EventName and tag.


Sign in to comment.

Accepted Answer

Deepak Gupta
Deepak Gupta on 28 Apr 2020
I am assuming your eventdata is a table(because you want to keep the variable names). Let's say event data has 2 columns one for source and other for Eventname, then you can add third column to this table by simply using dot(.) operator. i.e.
eventdata.tag = tag;
You can know more about tables here:


Saurav Roy
Saurav Roy on 28 Apr 2020
Hi !!,
Eventdata is actually an action data variable for a GUI. I tried doing that but it is throwing error
Unrecognized property 'tag' for class 'matlab.ui.eventdata.ActionData'.
Please find attached a screenshot of the eventdata variable.
Deepak Gupta
Deepak Gupta on 28 Apr 2020
I see your eventdata is not a table instead it's a data type which consists an object and a string.
You can modify this datatype to a new datatype which consists a double with property name Tag as below.
function obj = addTag(eventdata, tag)
obj.source = evnetdata.source;
obj.EventName = evnetdata.EventName;
obj.Tag = tag;
Call this function as:
eventdata = addTag(eventdata, tag);
I think it should work.
Saurav Roy
Saurav Roy on 28 Apr 2020
Thank you.. I will give it a try !!

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!