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

4 次查看(过去 30 天)
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

采纳的回答

Robert
Robert 2016-10-27
编辑:Robert 2016-10-27
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');

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by