How to allow a Matlab GUI using guide to have access to serial port objects

2 views (last 30 days)
So i have a little gui running and appears to be working. However one of the buttons is setup to execute a function that involves a serial port object that is live in the work space. The gui is throwing an error saying the the serial port object us undefined. So clearly it cannot not see all variables in the work space?
How do i get the gui to have access to all variables in the workspace? Or alt east one of them?
Thanks

Accepted Answer

Robert
Robert on 27 Oct 2016
Edited: Robert on 27 Oct 2016
Im going to answer my own question incase someone else needs this and how i fixed the issues
Simply adding the following command in the callback function allowed my gui to have access to the any variable in the base workspace. In this case Motor1 was the name of the variable i wanted in the gui and also happens to be serial port object. the keyword base allows access to the base workspace
Motor1 = evalin('base','Motor1');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!