0

我想用一个按钮加载一个神经网络对象文件,并在其他按钮的回调函数中使用它。

我没有使用 GUIDE,而是以编程方式创建 GUI。这是我的代码:

function ASR()

figure('Name','Automatic Isolated Speech Rcognition System',.......
   'Menubar','none',........
   'Color',[1 1 1]);

Rcrd_and_Recog =uicontrol('Style','pushbutton',....
                           'Units','normalized',....
                           'Position',[0.75 0.75 0.20 0.05],....
                           'String','START',....
                           'Callback',@Record_Recog);

LD_net = uicontrol('Style','pushbutton',....
                            'Units','normalized',....
                            'Position',[0.75 0.65 0.20 0.05],....
                            'String','LOAD THE NET',....
                            'Callback',@load_net);

function load_net(varargin)
    [file path]=uigetfile('*.mat','Select the M-file');
    if ~isequal(file, 0)
        L=load(fullfile(path,file));
        Net=fieldnames(L);
        net=Net{1};
        handles.net=net;
    end

 function Record_Recog(varargin)
     fs=16000;
     y=wavrecord(1*fs,fs,1,'double');

     if length(y)<1157
         result=sim(net0,cat(1,y,zeros(1157-length(y),1)))
     else
         result=sim(net0,y)
     end
 end

我加载了net变量,但无法从Rcrd_and_Recog. 我怎样才能达到它?

4

1 回答 1

0

我看不到 net0 是在哪里声明的。如果你想在不同的函数之间共享它们,你应该使用全局变量

于 2012-11-27T10:16:37.627 回答