MATLAB: Problems with a saved neural network

neural network

I've posted this question in another forum but decided to ask it here for a better chance at a response.
I'm having problems passing a neural network as a handle through a pushbutton callback. I use a menu to select the neural network file (mat file that was saved from a previous successful training session) and save this network as handles.neural_net = load('trained_net.mat'). Upon clicking the run neural network button, the network is run by netfunc(handles.neural_net, inputs,targets) where I've already specified the inputs and targets in the program. I get an error pointing within netfunc.m.
To make sure data was getting passed in, right under the function header within netfunc I put,
net inputs targets
The error points to the variable net. The size of net is 1×1. This is confusing because after the successful training run, I saved the network. I used save('trained_network.mat','net').

Best Answer

trained_net_vars = load('trained_net.mat');
handles.neural_net = trained_net_vars.net;