Search code examples
matlabneural-networkworkspacematlab-guide

Using Workspace variables in a GUI matlab


I have a workspace called finalnet. Inside the workspace i have a neural network called net. and I want to use the network in one of the functions in my GUI.

Is there a way to do that?

I tried to use evalin function : network = evalin('finalnet','net')

but i get this error:

Error using evalin Unknown command option.


Solution

  • From the wording of your problem it sounds like finalnet is a previously stored workspace such that finalnet.mat is located in some directory. Let's assume the current directory.

    In this case you need to load the workspace into your GUI. Assuming that's in some random callback function, you want to call load finalnet or load('finalnet.mat'). Now that the workspace is locally available to your callback function you may access your net.

    If you call load finalnet before you run your GUI then you would need to access net using net = evalin('base','net') inside your function. If you make any changes to net or other variables in the base workspace and you want those changes maintained even after exiting the GUI then you must call assignin('base','net'), or whichever variable you changed.