I need to add a variable that is user defined into 'eventdata' that is being generated using a GUI that I have made.
Example:
eventdata consists of Source and EventName.
I want to add another variable 'tag' such that now
eventdata consists of Source, EventName and tag.

 채택된 답변

Deepak Gupta
Deepak Gupta 2020년 4월 28일

0 개 추천

Hi,
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: https://in.mathworks.com/help/matlab/ref/table.html
Cheers.

댓글 수: 3

Saurav Roy
Saurav Roy 2020년 4월 28일
편집: Saurav Roy 2020년 4월 28일
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.
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;
end
Call this function as:
eventdata = addTag(eventdata, tag);
I think it should work.
cheers.
Saurav Roy
Saurav Roy 2020년 4월 28일
Thank you.. I will give it a try !!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2020년 4월 28일

댓글:

2020년 4월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by