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

4 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Robert
Robert el 27 de Oct. de 2016
Editada: Robert el 27 de Oct. de 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');

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by