How to take value of X and Y from plot put it in Text Edit field using button press in Matlab App?
Show older comments

Hello,
I want to extract value of X and Y from plot to Text edit field like I have attached image of my plot, Now on the X Axis I want only x value 5.1159m/s into my text field while press the button and on the Y Axis I want two value 1.01864 and 51.2092 into my text edit field. So, Could anyone help me, How to write code for this?
Answers (1)
Harald
on 29 Aug 2023
0 votes
Hi,
I have not tried within apps, but the getDataTips function from File Exchange may help you to extract the data from the data tips.
It is not clear to me how you decide what values should go into what edit field, but I suppose that is the easier task.
Best wishes,
Harald
8 Comments
Dhaval
on 31 Aug 2023
Harald
on 31 Aug 2023
Hi Dhaval,
if possible, please provide an example app.
Also I suppose that you are getting error messages? If so, please post the error message.
Best wishes,
Harald
Dhaval
on 1 Sep 2023
Harald
on 1 Sep 2023
Hi Dhaval,
The error message indicates that you are using an unsupported syntax of datacursormode. The following may work:
datacursormode(app.UIAxes2, 'on');
dcm = datacursormode;
There might be a simpler way, using the File Exchange function I have suggested.
I have created a little app that extracts data tips and displays them in a table. Looks good to me:

For further assistance, please provide an example app. It is just difficult to troubleshoot when only seeing a small bit of your application.
Best wishes,
Harald
Dhaval
on 1 Sep 2023
Harald
on 1 Sep 2023
Hi,
the code you are sharing is not using that function, and the code is not sufficient to reproduce the problem.
It seems like your axes is not called UIAxes2. Check the component browser within App Designer to verify that this is the correct name.
Best wishes,
Harald
Dhaval
on 4 Sep 2023
Harald
on 4 Sep 2023
Hi,
unfortunately, this is the only suggestion I can make from the code and error provided.
To further investigate for you, I would need a reproducible example. You would not have to share the full app, but enough to run the app and encounter the error message.
Best wishes,
Harald
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!