What I'm doing is creating a simple GUI. The problem I'm having right now is that it won't plot in the winow of the gui. Here's the code:
function varargout = gui(varargin)
% GUI Application M-file for gui.fig
% FIG = GUI launch gui GUI.
% GUI('callback_name', ...) invoke the named callback.
% Last Modified by GUIDE v2.0 06-Nov-2001 21:36:01
%global f1;
%global f2;
%global SNR1;
%global SNR2;
%global angle1;
%global angle2;
if nargin == 0 % LAUNCH GUI
fig = openfig(mfilename,'reuse');
% Use system color scheme for figure:
set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));
% Generate a structure of handles to pass to callbacks, and store it.
handles = guihandles(fig);
guidata(fig, handles);
if nargout > 0
varargout{1} = fig;
end
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
try
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
catch
disp(lasterr);
end
end
%| ABOUT CALLBACKS:
%| GUIDE automatically appends subfunction prototypes to this file, and
%| sets objects' callback properties to call them through the FEVAL
%| switchyard above. This comment describes that mechanism.
%|
%| Each callback subfunction declaration has the following form:
%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)
%|
%| The subfunction name is composed using the object's Tag and the
%| callback type separated by '_', e.g. 'slider2_Callback',
%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.
%|
%| H is the callback object's handle (obtained using GCBO).
%|
%| EVENTDATA is empty, but reserved for future use.
%|
%| HANDLES is a structure containing handles of components in GUI using
%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This
%| structure is created at GUI startup using GUIHANDLES and stored in
%| the figure's application data using GUIDATA. A copy of the structure
%| is passed to each callback. You can store additional information in
%| this structure at GUI startup, and you can change the structure
%| during callbacks. Call guidata(h, handles) after changing your
%| copy to replace the stored original so that subsequent callbacks see
%| the updates. Type "help guihandles" and "help guidata" for more
%| information.
%|
%| VARARGIN contains any extra arguments you have passed to the
%| callback. Specify the extra arguments by editing the callback
%| property in the inspector. By default, GUIDE sets the property to:
%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))
%| Add any extra arguments after the last argument, before the final
%| closing parenthesis.
% --------------------------------------------------------------------
function varargout = snrval1_Callback(h, eventdata, handles, varargin)
%global SNR1;
h_snr1=get(h,'string');
handles.snrval1=h_snr1;
guidata(h,handles);
%SNR1=str2num(get(handles.snrval1,'String'));
% --------------------------------------------------------------------
function varargout = snrval2_Callback(h, eventdata, handles, varargin)
%global SNR2;
h_snr2=get(h,'string');
handles.snrval2=h_snr2;
guidata(h,handles);
%SNR2=str2num(get(handles.snrval2,'String'));
% --------------------------------------------------------------------
function varargout = freq1_Callback(h, eventdata, handles, varargin)
%global f1;
h_f1=get(h,'string');
handles.freq1=h_f1;
guidata(h,handles);
%f1=str2num(get(handles.freq1,'String'));
% --------------------------------------------------------------------
function varargout = freq2_Callback(h, eventdata, handles, varargin)
%global f2;
h_f2=get(h,'string');
handles.freq2=h_f2;
guidata(h,handles);
%f2=str2num(get(handles.freq2,'String'));
% --------------------------------------------------------------------
function varargout = doa1_Callback(h, eventdata, handles, varargin)
%global angle1;
h_doa1=get(h,'string');
handles.doa1=h_doa1;
guidata(h,handles);
%angle1=str2num(get(handles.doa1,'String'))*pi/180;
% --------------------------------------------------------------------
function varargout = doa2_Callback(h, eventdata, handles, varargin)
%global angle2;
h_doa2=get(h,'string');
handles.doa2=h_doa2;
guidata(h,handles);
%angle2=str2num(get(handles.doa2,'String'))*pi/180;
% --------------------------------------------------------------------
function varargout = beamforming_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = music_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = update_Callback(h, eventdata, handles, varargin)
angle1=handles.doa1;
angle1=str2num(angle1);
angle2=handles.doa2;
angle2=str2num(angle2);
f1=handles.freq1;
f1=str2num(f1);
f2=handles.freq2;
f2=str2num(f2);
SNR1=handles.snrval1;
SNR1=str2num(SNR1);
SNR2=handles.snrval2;
SNR2=str2num(SNR2);
distance=1800;
c=1190;
n=-2*pi:.1:2*pi;
%n=(1:1000)/1000;
nfft=1024;
A1=10^(SNR1/20);
A2=10^(SNR2/20);
%axes(findobj('Tag','axes1'));
delay1=distance/c*sin(angle1*pi/180);
delay2=distance/c*sin(angle2*pi/180);
block=1:512;
sig1=A1*sin(2*pi*f1*n+delay1);
sig2=A1*sin(2*pi*f1*n);
sig3=A1*sin(2*pi*f1*n-delay1);
sig4=A2*sin(2*pi*f2*n+delay2);
sig5=A2*sin(2*pi*f2*n);
sig6=A2*sin(2*pi*f2*n-delay2);
plot(n,sig2,'b',n,sig5,'r');
% --------------------------------------------------------------------
function varargout = sound_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = reset_Callback(h, eventdata, handles, varargin)
% nothing
Anyone know how I can plot to the plot in the GUI? Right now, it plots in a new figure 🙁
function varargout = gui(varargin)
% GUI Application M-file for gui.fig
% FIG = GUI launch gui GUI.
% GUI('callback_name', ...) invoke the named callback.
% Last Modified by GUIDE v2.0 06-Nov-2001 21:36:01
%global f1;
%global f2;
%global SNR1;
%global SNR2;
%global angle1;
%global angle2;
if nargin == 0 % LAUNCH GUI
fig = openfig(mfilename,'reuse');
% Use system color scheme for figure:
set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));
% Generate a structure of handles to pass to callbacks, and store it.
handles = guihandles(fig);
guidata(fig, handles);
if nargout > 0
varargout{1} = fig;
end
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
try
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
catch
disp(lasterr);
end
end
%| ABOUT CALLBACKS:
%| GUIDE automatically appends subfunction prototypes to this file, and
%| sets objects' callback properties to call them through the FEVAL
%| switchyard above. This comment describes that mechanism.
%|
%| Each callback subfunction declaration has the following form:
%| <SUBFUNCTION_NAME>(H, EVENTDATA, HANDLES, VARARGIN)
%|
%| The subfunction name is composed using the object's Tag and the
%| callback type separated by '_', e.g. 'slider2_Callback',
%| 'figure1_CloseRequestFcn', 'axis1_ButtondownFcn'.
%|
%| H is the callback object's handle (obtained using GCBO).
%|
%| EVENTDATA is empty, but reserved for future use.
%|
%| HANDLES is a structure containing handles of components in GUI using
%| tags as fieldnames, e.g. handles.figure1, handles.slider2. This
%| structure is created at GUI startup using GUIHANDLES and stored in
%| the figure's application data using GUIDATA. A copy of the structure
%| is passed to each callback. You can store additional information in
%| this structure at GUI startup, and you can change the structure
%| during callbacks. Call guidata(h, handles) after changing your
%| copy to replace the stored original so that subsequent callbacks see
%| the updates. Type "help guihandles" and "help guidata" for more
%| information.
%|
%| VARARGIN contains any extra arguments you have passed to the
%| callback. Specify the extra arguments by editing the callback
%| property in the inspector. By default, GUIDE sets the property to:
%| <MFILENAME>('<SUBFUNCTION_NAME>', gcbo, [], guidata(gcbo))
%| Add any extra arguments after the last argument, before the final
%| closing parenthesis.
% --------------------------------------------------------------------
function varargout = snrval1_Callback(h, eventdata, handles, varargin)
%global SNR1;
h_snr1=get(h,'string');
handles.snrval1=h_snr1;
guidata(h,handles);
%SNR1=str2num(get(handles.snrval1,'String'));
% --------------------------------------------------------------------
function varargout = snrval2_Callback(h, eventdata, handles, varargin)
%global SNR2;
h_snr2=get(h,'string');
handles.snrval2=h_snr2;
guidata(h,handles);
%SNR2=str2num(get(handles.snrval2,'String'));
% --------------------------------------------------------------------
function varargout = freq1_Callback(h, eventdata, handles, varargin)
%global f1;
h_f1=get(h,'string');
handles.freq1=h_f1;
guidata(h,handles);
%f1=str2num(get(handles.freq1,'String'));
% --------------------------------------------------------------------
function varargout = freq2_Callback(h, eventdata, handles, varargin)
%global f2;
h_f2=get(h,'string');
handles.freq2=h_f2;
guidata(h,handles);
%f2=str2num(get(handles.freq2,'String'));
% --------------------------------------------------------------------
function varargout = doa1_Callback(h, eventdata, handles, varargin)
%global angle1;
h_doa1=get(h,'string');
handles.doa1=h_doa1;
guidata(h,handles);
%angle1=str2num(get(handles.doa1,'String'))*pi/180;
% --------------------------------------------------------------------
function varargout = doa2_Callback(h, eventdata, handles, varargin)
%global angle2;
h_doa2=get(h,'string');
handles.doa2=h_doa2;
guidata(h,handles);
%angle2=str2num(get(handles.doa2,'String'))*pi/180;
% --------------------------------------------------------------------
function varargout = beamforming_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = music_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = update_Callback(h, eventdata, handles, varargin)
angle1=handles.doa1;
angle1=str2num(angle1);
angle2=handles.doa2;
angle2=str2num(angle2);
f1=handles.freq1;
f1=str2num(f1);
f2=handles.freq2;
f2=str2num(f2);
SNR1=handles.snrval1;
SNR1=str2num(SNR1);
SNR2=handles.snrval2;
SNR2=str2num(SNR2);
distance=1800;
c=1190;
n=-2*pi:.1:2*pi;
%n=(1:1000)/1000;
nfft=1024;
A1=10^(SNR1/20);
A2=10^(SNR2/20);
%axes(findobj('Tag','axes1'));
delay1=distance/c*sin(angle1*pi/180);
delay2=distance/c*sin(angle2*pi/180);
block=1:512;
sig1=A1*sin(2*pi*f1*n+delay1);
sig2=A1*sin(2*pi*f1*n);
sig3=A1*sin(2*pi*f1*n-delay1);
sig4=A2*sin(2*pi*f2*n+delay2);
sig5=A2*sin(2*pi*f2*n);
sig6=A2*sin(2*pi*f2*n-delay2);
plot(n,sig2,'b',n,sig5,'r');
% --------------------------------------------------------------------
function varargout = sound_Callback(h, eventdata, handles, varargin)
% --------------------------------------------------------------------
function varargout = reset_Callback(h, eventdata, handles, varargin)
% nothing
Anyone know how I can plot to the plot in the GUI? Right now, it plots in a new figure 🙁