function varargout = f_sincos(varargin)
% FANQS_POLAR_TEST_20 Application M-file for fanqs_polar_test_20.fig
% FIG = FANQS_POLAR_TEST_20 launch fanqs_polar_test_20 GUI.
% FANQS_POLAR_TEST_20('callback_name', ...) invoke the named callback.
% Last Modified by GUIDE v2.0 13-Apr-2002 10:13:10
if nargin == 0 % LAUNCH GUI
% time = 1 ;
% save time time ;
fig = openfig(mfilename,'reuse');
handles = guihandles(fig);
% Use system color scheme for figure:
set(fig,'Color',get(0,'defaultUicontrolBackgroundColor'));
% F_Axes = axes( 'Position',[0.37, 0.20, 0.6, 0.75] ,...
% 'Box' , 'on' ,...
% 'Tag' , 'F_Axes') ;
%
% t = 0:1/50*pi:2*pi ;
% p = plot(t,sin(t)) ;
% handles.p = p ;
% Generate a structure of handles to pass to callbacks, and store it.
guidata(fig, handles);
if nargout > 0
varargout{1} = fig;
end
elseif ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
% load time time ;
% if time <= 30 ;
% time = time + 1 ;
% save time time ;
% else
% fanqs_polar_test_20 ;
% end
try
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
catch
disp(lasterr);
end
end
% --------------------------------------------------------------------
function varargout = Model_Callback(gcbf, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.togglebutton3.
% save current results
handles = guihandles( gcbf ) ;
t = 0 : 1/30*pi : 8*pi ;
p_func = { 'p = sin(t)+3*cos(t/2)' ;...
'p = sin(2*t)+3*cos(t/2)' ;...
'p = sin(4*t)+2*cos(t/2)' ;...
'p = sin(2*t)+0.5*cos(t/2)' ;...
'p = 2*sin(2*t)+0.5*cos(t/2)' ;...
'p = 2*sin(3*t)+0.5*cos(t/4)' ;...
'p = 2*sin(-1.5*t)+3*cos(t/2)' ;...
'p = -4*sin(-3*t)-3*cos(-3*t)' ;...
'p = 4*sin(-4*t)+2.5*cos(2*t)' ;...
'p = 2*sin(2*t)+cos(1/2*t)' ;...
'p = sin(2*t)+cos(1/2*t)' ;...
'p = sin(4*t)-4*cos(1*t)' ;...
'p = -2*sin(3*t)-4*cos(0.5*t)' ;...
'p = -2*sin(6*t)-4*cos(2*t)' ;...
'p = -3*sin(3*t)-4*cos(2*t)' ;...
'p = -3*sin(3*t)+0.5*cos(2*t)' ;...
'p = sin(t)+cos(t)' ;...
'p = sin(2*t)+0.5*cos(t/2)' ;...
'p = sin(4*t)+cos(t/2)' ;...
'p = sin(t)+3*cos(t/2)' } ;
p_func(21:40,1) = p_func ;
for i = 1:40
output_function = p_func(i) ;
output_function = char(output_function) ;
eval([output_function,' ;']) ;
n = (mod(i,20) ~= 0)*mod(i,20) + (mod(i,20) == 0)*20 ;
n = sprintf( '%s',num2str(n)) ;
output_function = ['No.',n,' ',output_function] ;
set( handles.output_function, 'string', output_function ) ;
% delete(handles.p) ;
delete(gca) ;
F_Axes = axes( 'Position',[0.37, 0.20, 0.6, 0.75] ,...
'Box' , 'on' ,...
'Tag' , 'F_Axes') ;
subplot(F_Axes);
if i <= 20
p = polar(t,p,'r') ;
handles.p = p ;
else
p= plot(t,p,'b') ;
handles.p = p ;
end
pause(1.5) ;
end
% --------------------------------------------------------------------
function varargout = Rand_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.togglebutton3.
T = 20*pi ;
t = 0:1/30*pi:T ;
a = round(rand*16)/4 - 2 ;
b = round(rand*16)/4 - 2 ;
c = round(rand*16)/4 - 2 ;
d = round(rand*16)/4 - 2 ;
p = a*sin(b*t) + c*cos(d*t) ;
% Take the expression to the interface.
output_function = outplus_expression(a,b,c,d) ;
set( handles.output_function, 'string', output_function ) ;
delete(gca) ;
F_Axes = axes('Position',[0.35, 0.20, 0.6, 0.75] ,...
'Box' , 'on' ,...
'Tag' , 'F_Axes') ;
subplot(F_Axes);
hold off ;
polar(t,p,'r') ;
axis off ;
% --------------------------------------------------------------------
function varargout = Plot_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.Plot.
% save current results
handles = guihandles( h ) ;
guidata(h, handles);
% Take the value of function coefficient ( t , a , b , c , d ) .
[t,a,b,c,d] = take_value ;
% Take the expression
p = ( a*sin(b*t) + c*cos(d*t) ) ;
% Take the expression to the interface.
output_function = outplus_expression(a,b,c,d) ;
set( handles.output_function, 'string', output_function ) ;
delete(gca) ;
F_Axes = axes('Position',[0.35, 0.20, 0.6, 0.75] ,...
'Box' , 'on' ,...
'Tag' , 'F_Axes') ;
subplot(F_Axes);
plot(t,p) ;
if get(handles.Grid, 'Value' ) == 0
set(F_Axes,'XGrid','off','YGrid','off');
axis off ;
else
set(F_Axes,'GridLineStyle','--','XGrid','on','YGrid','on');
end
% --------------------------------------------------------------------
function varargout = Polar_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton2.
% save current results
handles = guihandles( h ) ;
guidata(h, handles);
% Take the value of function coefficient ( t , a , b , c , d ) .
[t,a,b,c,d] = take_value ;
p = ( a*sin(b*t) + c*cos(d*t) ) ;
% Take the expression to the interface.
output_function = outplus_expression(a,b,c,d) ;
set( handles.output_function, 'string', output_function ) ;
% hold off ;
delete(gca) ;
F_Axes = axes('Position',[0.35, 0.20, 0.6, 0.75] ,...
'Box' , 'on' ,...
'Tag' , 'F_Axes') ;
axis off ;
subplot(F_Axes);
hold off
polar(t,p,'r') ;
% --------------------------------------------------------------------
function varargout = Plot3_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton2.
% save current results
handles = guihandles( h ) ;
guidata(h, handles);
% Take the value of function coefficient ( t , a , b , c , d ) .
[t,a,b,c,d] = take_value ;
% Take the expression
x = a*sin(b*t) ;
y = c*cos(d*t) ;
z = t ;
% z = ( a*sin(b*t) + c*cos(d*t) ) ;
a = sprintf( '%s' , num2str(a) ) ;
b = sprintf( '%s' , num2str(b) ) ;
c = sprintf( '%s' , num2str(c) ) ;
d = sprintf( '%s' , num2str(d) ) ;
% Take the expression to the interface.
output_function = ['x = ',a,'*sin(',b,'*t)','; y = ',c,'*cos(',d,'*t);',' z = t.'] ;
set( handles.output_function, 'string', output_function ) ;
delete(gca) ;
F_Axes = axes('Position',[0.35, 0.20, 0.6, 0.75] ,...
'Box' , 'on' ,...
'Tag' , 'F_Axes') ;
subplot(F_Axes);
plot3(x,y,z) ;
if get(handles.Grid, 'Value' ) == 0
set(F_Axes,'XGrid','off','YGrid','off','ZGrid','off');
else
set(F_Axes,'GridLineStyle','--','XGrid','on','YGrid','on','ZGrid','on');
end
% --------------------------------------------------------------------
function varargout = Color_Callback(h, eventdata, handles, varargin)
% Stub for Callback of the uicontrol handles.pushbutton2.
handles = guihandles(h);
guidata(h, handles);
% r = 1 - rand/3 ;
% g = 1 - rand/3 ;
% b = 1 - rand/3 ;
c = 2.6 + rand * 0.1 ;
if c <= 1
r = rand * c ;
g = rand * (c - r) ;
b = c - r - g ;
elseif (c > 1) & (c <= 2)
r = rand ;
if r < (c - 1)
g = (c - 1 - r) + rand * (2 - c + r) ;
else
g = rand * (c - r) ;
end
b = c - r - g ;
elseif (c > 2) & (c <= 3)
r = (c - 2) + rand * (3 - c) ;
g = (c - r - 1) + rand * (2 - c + r) ;
b = c - r - g ;
end
set(gcbf,'Color',[r g b]) ;
set(handles.Color,'BackgroundColor',[r g b]) ;
set(handles.Grid,'BackgroundColor',[r g b]) ;
set(handles.Model,'BackgroundColor',[r g b]) ;
set(handles.Plot,'BackgroundColor',[r g b]) ;
set(handles.Plot3,'BackgroundColor',[r g b]) ;
set(handles.Rand,'BackgroundColor',[r g b]) ;
set(handles.Polar,'BackgroundColor',[r g b]) ;
set(handles.Exit,'BackgroundColor',[r g b]) ;
c = c + 0.2 ;
if c <= 1
r = rand * c ;
g = rand * (c - r) ;
b = c - r - g ;
elseif (c > 1) & (c <= 2)
r = rand ;
if r < (c - 1)
g = (c - 1 - r) + rand * (2 - c + r) ;
else
g = rand * (c - r) ;
end
b = c - r - g ;
elseif (c > 2) & (c <= 3)
r = (c - 2) + rand * (3 - c) ;
g = (c - r - 1) + rand * (