²é¿´: 2115  |  »Ø¸´: 13

ÍûÔÂÈÎ

гæ (СÓÐÃûÆø)

[ÇóÖú] matlab guiÇóÖú ÒÑÓÐ2È˲ÎÓë

ÈçºÎ´´½¨Ò»¸ö°´Å¥µ÷ÓÃMÎļþ£¬²¢½«ÏÔʾÔÚÏÔʾÔÚÒ»¸öÎı¾¿òÖУ¬Èçͼµã»÷ÄǸöä¯ÀÀ°´Å¥Ëùʾ¡£Ð»Ð»´ó¼Ò

matlab guiÇóÖú
2YKN`C86P@ZR]7}V5BXS]WO.png


matlab guiÇóÖú-1
YAO(R~RDP([420[T0B8$0]A.png


matlab guiÇóÖú-2
]O[26OH(QL7YKRV[4K~R5%C.png
»Ø¸´´ËÂ¥

» ²ÂÄãϲ»¶

» ±¾Ö÷ÌâÏà¹Ø¼ÛÖµÌùÍÆ¼ö£¬¶ÔÄúͬÑùÓаïÖú:

ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

achilFes1990

ľ³æ (ÖøÃûдÊÖ)

¡¾´ð°¸¡¿Ó¦Öú»ØÌû

¸Ðл²ÎÓ룬ӦÖúÖ¸Êý +1
ÏȰ´ÕÕ°ïÖúÎĵµ»òÕß°¸Àý×öÒ»Á½¸öÀý×Ó°É£¬ÕâÖÖ°´Å¥µ÷ÓÃcallbackº¯ÊýµÄÀý×Ó£¬´ó²¿·Ö²Î¿¼ÊéÀïÃæ¶¼ÓУ¬ÄãÕÕ×Å×ö¾ÍÐÐÁË

[ ·¢×ÔÊÖ»ú°æ http://muchong.com/3g ]
ɨһɨ¹Ø×¢ÎÒµÄ΢ÐŹ«Öںţ¬¹²Í¬Ñ§Ï°´¬²°CFD
2Â¥2015-11-29 14:24:46
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

ÍûÔÂÈÎ

гæ (СÓÐÃûÆø)

ÒýÓûØÌû:
2Â¥: Originally posted by achilFes1990 at 2015-11-29 14:24:46
ÏȰ´ÕÕ°ïÖúÎĵµ»òÕß°¸Àý×öÒ»Á½¸öÀý×Ó°É£¬ÕâÖÖ°´Å¥µ÷ÓÃcallbackº¯ÊýµÄÀý×Ó£¬´ó²¿·Ö²Î¿¼ÊéÀïÃæ¶¼ÓУ¬ÄãÕÕ×Å×ö¾ÍÐÐÁË

Õâ¸ö¾ÍÊDZðÈË×öµÄÀý×Ó£¬ÎÒÊÔ×ÅËûµÄ·½·¨×öû×ö³öÀ´£¬ÏëÎÊÎÊ´ó¼ÒÔõô×öµÄ
3Â¥2015-11-29 14:26:28
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

onelightwang

½ð³æ (СÓÐÃûÆø)

¡¾´ð°¸¡¿Ó¦Öú»ØÌû

¸Ðл²ÎÓ룬ӦÖúÖ¸Êý +1
ÒýÓûØÌû:
3Â¥: Originally posted by ÍûÔÂÈÎ at 2015-11-29 14:26:28
Õâ¸ö¾ÍÊDZðÈË×öµÄÀý×Ó£¬ÎÒÊÔ×ÅËûµÄ·½·¨×öû×ö³öÀ´£¬ÏëÎÊÎÊ´ó¼ÒÔõô×öµÄ...

Èç¹ûÊÇÔËÐбðÈ˵ÄÀý×Ó£¬Â¥Ö÷ÐèҪעÒâÁ½¸öµØ·½£º
1.º¯ÊýÖÐÎļþµÄ·¾¶ÊÇ·ñÕýÈ·¡£
2.º¯ÊýËùÔÚ·¾¶ÊÇ·ñÌí¼Óµ½matlabµÄ·¾¶ÖС£
4Â¥2015-11-29 16:14:41
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

ÍûÔÂÈÎ

гæ (СÓÐÃûÆø)

ÒýÓûØÌû:
4Â¥: Originally posted by onelightwang at 2015-11-29 16:14:41
Èç¹ûÊÇÔËÐбðÈ˵ÄÀý×Ó£¬Â¥Ö÷ÐèҪעÒâÁ½¸öµØ·½£º
1.º¯ÊýÖÐÎļþµÄ·¾¶ÊÇ·ñÕýÈ·¡£
2.º¯ÊýËùÔÚ·¾¶ÊÇ·ñÌí¼Óµ½matlabµÄ·¾¶ÖС£...

±ðÈ˵ÄÎÒÔËÐгöÀ´ÁË£¬ÕÕ×ÅËû·Â³öÁ˵ãÎÊÌâ
5Â¥2015-11-29 18:36:53
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

µÛ_×ð

ľ³æ (ÕýʽдÊÖ)

¿ÉÄÜÊÇËûµÄ°æ±¾ºÍÄãÓõIJ»Í¬

·¢×ÔСľ³æAndroid¿Í»§¶Ë
6Â¥2015-11-29 18:37:59
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

onelightwang

½ð³æ (СÓÐÃûÆø)

» ±¾ÌûÒÑ»ñµÃµÄºì»¨£¨×îÐÂ10¶ä£©

7Â¥2015-11-30 19:20:48
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

ÍûÔÂÈÎ

гæ (СÓÐÃûÆø)

ÒýÓûØÌû:
7Â¥: Originally posted by onelightwang at 2015-11-30 19:20:48
Ìù´úÂë

function varargout = DemoGUI(varargin)
% DEMOGUI M-file for DemoGUI.fig
%      DEMOGUI, by itself, creates a new DEMOGUI or raises the existing
%      singleton*.
%
%      H = DEMOGUI returns the handle to a new DEMOGUI or the handle to
%      the existing singleton*.
%
%      DEMOGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DEMOGUI.M with the given input arguments.
%
%      DEMOGUI('Property','Value',...) creates a new DEMOGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before DemoGUI_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to DemoGUI_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help DemoGUI

% Last Modified by GUIDE v2.5 16-Apr-2005 18:42:13

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @DemoGUI_OpeningFcn, ...
                   'gui_OutputFcn',  @DemoGUI_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before DemoGUI is made visible.
function DemoGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to DemoGUI (see VARARGIN)

% Choose default command line output for DemoGUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes DemoGUI wait for user response (see UIRESUME)
% uiwait(handles.DemoFig);

% ÈÕÆÚʱ¼äÏÔʾ
set(handles.timestr,'string',datestr(now,0));
htimer = timer('StartDelay',1,'TimerFcn',...
    'htimestr=findall(0,''tag'',''timestr'');set(htimestr,''string'',datestr(now,0));',...
    'Period',1,'ExecutionMode','fixedSpacing','tag','showtime');
start(htimer);

set(hObject,'doublebuffer','on');



% --- Outputs from this function are returned to the command line.
function varargout = DemoGUI_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



% --- Executes on button press in ExitBtn.
function ExitBtn_Callback(hObject, eventdata, handles)
% hObject    handle to ExitBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

selection = questdlg(['Í˳ö ' get(handles.DemoFig,'Name') '?'],...
                     ['Í˳ö ' get(handles.DemoFig,'Name') '...'],...
                     'ÊÇ','·ñ','ÊÇ');
if strcmp(selection,'·ñ')
    return;
end
htimer = timerfind('tag','showtime');
stop(htimer);
delete(htimer);
delete(handles.DemoFig);

% --- Executes on button press in HelpBtn.
function HelpBtn_Callback(hObject, eventdata, handles)
% hObject    handle to HelpBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% str={'¶Ô²»Æð£¬Ä¿Ç°ÉÐδÍê³É˵Ã÷Îļþ';' ´òË㾡¿ìÍêÉÆÕû¸öϵͳ¹¦Äܼ°ÆäʹÓÃ˵Ã÷'};
% msgbox(str,'ʹÓðïÖú','help','non-modal');
!CNCHelp.CHM


% ¾«²å²¹°´Å¥»Øµ÷º¯Êý
% --- Executes on button press in JinBtn.
function JinBtn_Callback(hObject, eventdata, handles)
% hObject    handle to JinBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% »ñÈ¡ÉèÖõIJÎÊýÖµ
theta0 = get(handles.startRad,'UserData'); % ÍâÂÖÀªÆðʼµã¼«½Ç
thetat = get(handles.endRad,'UserData'); % ÍâÂÖÀªÖÐÖ¹µã¼«½Ç
interpTime = get(handles.interpT,'UserData'); % ²å²¹ÖÜÆÚ ms
mihuaNum = get(handles.miHuaNum,'UserData'); % ÃÜ»¯µãÊý
jinjiV = get(handles.jinjiV,'UserData'); % ½ø¸øËÙ¶È mm/min
jinjiV = jinjiV/60; % ½ø¸øËÙ¶Èmm/sec
clrjinline = get(handles.clrJin,'BackgroundColor'); % ¾«²åÖµµãÏßÑÕÉ«
% »ñÈ¡ÍâÂÖÀªº¯ÊýÃû
filename = get(handles.SelectFcnBtn,'UserData');
if isempty(filename)
    msgbox('ûÓÐѡȡÂÖÀªº¯Êý£¡','²Ù×÷´íÎó');
    return;
end
[pathstr,fcnname] = fileparts(filename); %»ñµÃÎļþÃûÓë·¾¶Ãû
% ÅжÏÊÇ˳Բ»¹ÊÇÄæÔ²²å²¹,ʵÏÖ²»¹Ü˳Բ»¹ÊÇÄæÔ²¶¼¿ÉÓ㨲»¹ýÖ»²âÊÔÁË˳Բ£­£­ÄæÊ±Õë²å²¹£©
if theta0>thetat    % ÄæÔ²
    flag = -1;
else           % ˳Բ
    flag = 1;
end
set(gcf,'doublebuffer','on');
axis(handles.axes2); % ÉèÖÃaxes2Ϊµ±Ç°×ø±êÖá
hjinline = line('color',clrjinline,'marker','.','markersize',4,...
                     'visible','off', 'tag','jinline'); % ´´½¨´Ö²åÖµÏß¶ÔÏó  
culinedata = getappdata(handles.CuBtn,'culinedata');  % »ñÈ¡´Ö²å²¹ÏßÊý¾Ý
cutheta = culinedata(:,1);  % ¼«½Ç
curho = culinedata(:,2); % ¼«¾¶
numCu = length(culinedata); % ´Ö²å²¹µãÊý
theta = [];
r = [];
set(hjinline,'visible','on');
outflag = 0;
% hbar = waitbar(0,'Please wait...','name','¾«²å²¹½øÐÐÖÐ');
for k = 1:numCu-1 % ¶Ôÿ¶Î´Ö²å²¹Çé¿ö
    tmptheta = cutheta(k); % theta0
    rr0 = curho(k); % rho0
    theta = [theta tmptheta];
    r = [r rr0];
    [xd,yd] = pol2cart(theta,r); % ¼«×ø±ê±ä³ÉÆ½ÃæÖ±½Ç×ø±ê
    set(hjinline,'xdata',xd,'ydata',yd);
    for n = 2:mihuaNum % ¼ÆËãÿ¶Î´Ö²å²¹ÖÐÃÜ»¯µã×ø±ê
        drda = drdtheta(fcnname,tmptheta); % ¼ÆËã¸ÃµãµÄÊýֵ΢·Ö
        deletatheta = interpTime/1000*jinjiV/(drda^2+rr0^2)^(0.5); % ¼ÆËãdeltatheta
        tmptheta = flag*deletatheta+tmptheta; % µü´úÇóÈ¡ÏÂÒ»¸ö¼«½Ç
        if flag*tmptheta>flag*cutheta(end) % ¶ÔÓÚ×îºóÒ»¶ÎµÄÌØÊâ´¦Àí,ÒòΪ×îºóÒ»¶Î¿ÉÄܱÈÒÔǰµÄ¶Ì
            tmptheta = cutheta(end); % ÊDz»Äܹ»²åÈënum¸öÃÜ»¯µãµÄ
            outflag = 1;
        end
        rr0 = feval(fcnname,tmptheta);
        theta = [theta tmptheta];
        r = [r rr0];
        [xd,yd] = pol2cart(theta,r);
        set(hjinline,'xdata',xd,'ydata',yd);
        if outflag==1
            break;  % ×îºóÒ»¶ÎÌØÊâ´¦ÀíÊ±Ìø³öÑ­»·
        end
    end
%     waitbar(k/(numCu-1),hbar);
end
% close(hbar);
theta = [theta cutheta(end)];
r = [r curho(end)];
jinlinedata = [theta( r(];
setappdata(hObject,'jinlinedata',jinlinedata); % ±£´æ¾«²å²¹ÏßÊý¾Ýµ½¾ä±úÖÐ
set(handles.chkJin,'enable','on'); % ʹµÃÏÔʾÒþ²ØÏ߸´Ñ¡¿ò¿ÉÓÃ
chkLegend_Callback(handles.chkLegend,[], handles);



% ´Ö²å²¹°´Å¥»Øµ÷º¯Êý
% --- Executes on button press in CuBtn.
function CuBtn_Callback(hObject, eventdata, handles)
% hObject    handle to CuBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% »ñÈ¡ÉèÖõIJÎÊýÖµ
theta0 = get(handles.startRad,'UserData'); % ÍâÂÖÀªÆðʼµã¼«½Ç
thetat = get(handles.endRad,'UserData'); % ÍâÂÖÀªÖÐÖ¹µã¼«½Ç
interpTime = get(handles.interpT,'UserData'); % ²å²¹ÖÜÆÚ ms
jinjiV = get(handles.jinjiV,'UserData'); % ½ø¸øËÙ¶È mm/min
jinjiV = jinjiV/60; % ½ø¸øËÙ¶Èmm/sec
clrlunline = get(handles.clrLun,'BackgroundColor'); % ÂÖÀªÏßÑÕÉ«
clrculine = get(handles.clrCu,'BackgroundColor'); % ´Ö²åÖµµãÏßÑÕÉ«

% »ñÈ¡ÍâÂÖÀªº¯ÊýÃû
filename = get(handles.SelectFcnBtn,'UserData');
if isempty(filename)
    msgbox('ûÓÐѡȡÂÖÀªº¯Êý£¡','²Ù×÷´íÎó');
    return;
end
[pathstr,fcnname] = fileparts(filename);
addpath(pathstr,'-begin');  % ½«ÍâÂÖÀªº¯ÊýËùÔÚ·¾¶¼ÓÈëmatlab·¾¶ÖÐ

set(handles.chklun,'enable','on'); % ʹ¸´Ñ¡¿ò¿ÉÓÃ
set(handles.chkLegend,'enable','on'); % ʹ¸´Ñ¡¿ò¿ÉÓÃ
set(handles.chkCu,'enable','on'); % ʹ¸´Ñ¡¿ò¿ÉÓÃ

% »æÖÆÍâÂÖÀªÏß
theta = linspace(theta0,thetat,1000);
r = feval(fcnname,theta); % ¼ÆËãÍâÂÖÀª
if length(r)~=length(theta)  % ͨ³£ÊÇÓÉÓÚÍâÂÖÀªº¯Êý²»¶ÔÔì³É
    msgbox('ÍâÂÖÀªº¯Êý´íÎó','³ö´íÁË...');
    return;
end
axis(handles.axes2);
hlunline = polar(theta,r);
set(hlunline,'color',clrlunline,'tag','lunline'); % ÉèÖÃtagÒÔºóºÃÓÃ
lundata = [theta( r(];
setappdata(hObject,'lundata',lundata); % ±£´æÂÖÀªÏßÊý¾Ýµ½¾ä±úÖÐ
hold on;
hculine = line('color',clrculine,'marker','.','markersize',10,...
                       'tag','culine'); % ´Ö²åÖµÏß¶ÔÏó  'erasemode','xor',
hold off;                 
theta = [];
r = [];
% ÅжÏÊÇ˳Բ»¹ÊÇÄæÔ²²å²¹,ʵÏÖ²»¹Ü˳Բ»¹ÊÇÄæÔ²¶¼¿ÉÓ㨲»¹ýÖ»²âÊÔÁË˳Բ£­£­ÄæÊ±Õë²å²¹£©
if theta0>thetat    % ÄæÔ²
    flag = -1;
else           % ˳Բ
    flag = 1;
end
tmptheta = theta0;
while flag*tmptheta<flag*thetat  % ÖÕÖ¹Åжϣ¬¿¼ÂÇÁË˳ԲÓëÄæÔ²
    rr0 = feval(fcnname,tmptheta); % ¼ÆËãÍâÂÖÀª¸Ã¼«½Ç³öµÄ¼«¾¶
    theta = [theta tmptheta];
    r = [r rr0];
    [xd,yd] = pol2cart(theta,r); % ת»»ÎªÖ±½Ç×ø±êϵÊýÖµ
    set(hculine,'xdata',xd,'ydata',yd); % ¸üвåÖµµã
    drda = drdtheta(fcnname,tmptheta); % ¼ÆËã¸Ã¼«½Ç´¦Êýֵ΢·Ö
    deletatheta = interpTime/1000*jinjiV/(drda^2+rr0^2)^(0.5);
    tmptheta = flag*deletatheta+tmptheta; % µü´úÇóÈ¡ÏÂÒ»¸öµã¼«½Ç
end
rr0 = feval(fcnname,thetat); % ÖÕµã¼ÓÈë
theta = [theta thetat];
r = [r rr0];
culinedata = [theta( r(];
setappdata(hObject,'culinedata',culinedata); % ±£´æ´Ö²å²¹ÏßÊý¾Ýµ½¾ä±úÖÐ

set(handles.ExportDataBtn,'enable','on');
set(handles.JinBtn,'enable','on');
chkLegend_Callback(handles.chkLegend,[], handles); % µ÷ÓÃͼÀý¸´Ñ¡¿òµÄ»Øµôº¯Êý

% --- Executes during object creation, after setting all properties.
function FcnName_CreateFcn(hObject, eventdata, handles)
% hObject    handle to FcnName (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end




% --- Executes on button press in SelectFcnBtn.
function SelectFcnBtn_Callback(hObject, eventdata, handles)
% hObject    handle to SelectFcnBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

[filename, pathname] = uigetfile('*.m', 'ѡȡÍâÂÖÀªÏßMÎļþ');
if filename~=0
    set(handles.FcnName,'string',filename);
    set(hObject,'UserData',[pathname filename]);
    set(handles.JinBtn,'enable','off');
    set(handles.ExportDataBtn,'enable','off');
    set(handles.chklun,'enable','off');
    set(handles.chkCu,'enable','off');
    set(handles.chkJin,'enable','off');
    set(handles.chkLegend,'value',0,'enable','off');
    axis(handles.axes2);
    cla
    chkLegend_Callback(handles.chkLegend,[], handles); % ¸üÐÂͼÁÐ
else
    set(handles.FcnName,'string','ÉÐδѡȡ');
end


% --- Executes on button press in ExportDataBtn.
function ExportDataBtn_Callback(hObject, eventdata, handles)
% hObject    handle to ExportDataBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% str={'¶Ô²»Æð£¬Ä¿Ç°ÉÐδÍê³É˵Ã÷Îļþ';' ´òË㾡¿ìÍêÉÆÕû¸öϵͳ¹¦Äܼ°ÆäʹÓÃ˵Ã÷'};
% msgbox(str,'ʹÓðïÖú','help','non-modal');

type = get(handles.dataType,'UserData'); % »ñÈ¡ÉèÖõĵ¼³öÊý¾Ý¸ñʽ 1-mat,2-txt,3-dat

% % »ñÈ¡¸÷ÖÖͼÏߵľä±ú
% hjinline = findobj(0,'tag','jinline');
% hculine = findobj(0,'tag','culine');
% hlunline = findobj(0,'tag','lunline');
% ±£´æÊ±
% % handles.CuBtn
% setappdata(hObject,'culinedata',culinedata); % ±£´æ´Ö²å²¹ÏßÊý¾Ýµ½¾ä±úÖÐ
% setappdata(hObject,'lundata',lundata); % ±£´æÂÖÀªÏßÊý¾Ýµ½¾ä±úÖÐ
% % handles.JinBtn
% setappdata(hObject,'jinlinedata',jinlinedata); % ±£´æ¾«²å²¹ÏßÊý¾Ýµ½¾ä±úÖÐ
lundata = getappdata(handles.CuBtn,'lundata');
culinedata = getappdata(handles.CuBtn,'culinedata');
jinlinedata = getappdata(handles.JinBtn,'jinlinedata');

switch type
    case 1,
        [filename, pathname] = uiputfile('*.mat', '±£´æ²å²¹½á¹û');
        if filename==0 % È¡Ïû
            return;
        end
        save([pathname filename],'lundata','culinedata','jinlinedata');
    case 2,
        [filename, pathname] = uiputfile('*.txt', '±£´æ²å²¹½á¹û');
        if filename==0
            return;
        end
        [pathstr,filename]=fileparts(filename);
        fid = fopen([pathname filename,'.txt'],'w');
        fprintf(fid,'\n£¥=================%s=================\r\n',datestr(now,0));
        fprintf(fid,'£¥Ô­Ê¼ÍâÂÖÀªÏßÊý¾Ý\r\n');
        fprintf(fid,'£¥ ¼«½Ç     \t   ¼«¾¶\r\n');
        fprintf(fid,'%8.6f  \t  %8.6f\r\n',lundata');
        fprintf(fid,'£¥´Ö²å²¹µãÊý¾Ý\r\n');
        fprintf(fid,'£¥ ¼«½Ç     \t   ¼«¾¶\r\n');
        fprintf(fid,'%8.6f  \t  %8.6f\r\n',culinedata');
        fprintf(fid,'£¥¾«²å²¹µãÊý¾Ý\r\n');
        fprintf(fid,'£¥ ¼«½Ç     \t   ¼«¾¶\r\n');
        fprintf(fid,'%8.6f  \t  %8.6f\r\n',jinlinedata');
        fclose(fid);   
    case 3,
        [filename, pathname] = uiputfile('*.dat', '±£´æ²å²¹½á¹û');
        if filename==0
            return;
        end
        [pathstr,filename]=fileparts(filename);
        save([pathname filename,'.dat'],'lundata','culinedata','jinlinedata','-ascii','-double');
    otherwise,
        msgbox('ÕÕµÀÀíÊDz»»á³öÏÖµÄ~');
end






% --- Executes on button press in ResetBtn.
function ResetBtn_Callback(hObject, eventdata, handles)
% hObject    handle to ResetBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% ÉèÖø÷ÖÖ²ÎÊýΪĬÈÏÖµ
set(handles.startRad,'string','0','UserData',0);
set(handles.endRad,'string','2*pi','UserData',2*pi);
set(handles.miHuaNum,'string','4','UserData',4);
set(handles.interpT,'string','8','UserData',8);
set(handles.jinjiV,'string','4000','UserData',4000);
set(handles.clrLun,'BackgroundColor',[0 0 0]);
set(handles.clrCu,'BackgroundColor',[0 0 1]);
set(handles.clrJin,'BackgroundColor',[1 1 0.5]);
set(handles.dataType,'value',1,'UserData',1);
set(handles.chkLegend,'value',0,'UserData',0);


% --- Executes during object creation, after setting all properties.
function startRad_CreateFcn(hObject, eventdata, handles)
% hObject    handle to startRad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function startRad_Callback(hObject, eventdata, handles)
% hObject    handle to startRad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of startRad as text
%        str2double(get(hObject,'String')) returns contents of startRad as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data)  % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end


% --- Executes during object creation, after setting all properties.
function endRad_CreateFcn(hObject, eventdata, handles)
% hObject    handle to endRad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function endRad_Callback(hObject, eventdata, handles)
% hObject    handle to endRad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of endRad as text
%        str2double(get(hObject,'String')) returns contents of endRad as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data) % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end



% --- Executes during object creation, after setting all properties.
function miHuaNum_CreateFcn(hObject, eventdata, handles)
% hObject    handle to miHuaNum (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function miHuaNum_Callback(hObject, eventdata, handles)
% hObject    handle to miHuaNum (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of miHuaNum as text
%        str2double(get(hObject,'String')) returns contents of miHuaNum as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data) % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end



% --- Executes during object creation, after setting all properties.
function interpT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to interpT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function interpT_Callback(hObject, eventdata, handles)
% hObject    handle to interpT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of interpT as text
%        str2double(get(hObject,'String')) returns contents of interpT as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data) % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end



% --- Executes during object creation, after setting all properties.
function jinjiV_CreateFcn(hObject, eventdata, handles)
% hObject    handle to jinjiV (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function jinjiV_Callback(hObject, eventdata, handles)
% hObject    handle to jinjiV (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of jinjiV as text
%        str2double(get(hObject,'String')) returns contents of jinjiV as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data) % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end


% --- Executes during object creation, after setting all properties.
function dataType_CreateFcn(hObject, eventdata, handles)
% hObject    handle to dataType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in dataType.
function dataType_Callback(hObject, eventdata, handles)
% hObject    handle to dataType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns dataType contents as cell array
%        contents{get(hObject,'Value')} returns selected item from dataType

% 1 - mat; 2 - txt ; 3 - dat
datatype = get(hObject,'Value');
set(hObject,'UserData',datatype);


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over clrLun.
function clrLun_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to clrLun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% ÑÕÉ«ÉèÖô¦Àí
color = uisetcolor;
if length(color)~=1 % Èç¹ûѡȡÁËÑÕÉ«
    set(hObject,'BackgroundColor',color);
    hlunline = findobj(0,'tag','lunline');
    if ~isempty(hlunline) % Èç¹ûÒÑ»æÖÆÍ¼Ïߣ¬Ôò°´ÕÕÉèÖõÄÑÕÉ«¸üÐÂͼÏß
        set(hlunline,'color',color);
    end
end

% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over clrJin.
function clrJin_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to clrJin (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

color = uisetcolor;
if length(color)~=1
    set(hObject,'BackgroundColor',color);
    hjinline = findobj(0,'tag','jinline');
    if ~isempty(hjinline) % Èç¹ûÒÑ»æÖÆÍ¼Ïߣ¬Ôò°´ÕÕÉèÖõÄÑÕÉ«¸üÐÂͼÏß
        set(hjinline,'color',color);
    end
end


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over clrCu.
function clrCu_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to clrCu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

color = uisetcolor;
if length(color)~=1
    set(hObject,'BackgroundColor',color);
    hculine = findobj(0,'tag','culine');
    if ~isempty(hculine) % Èç¹ûÒÑ»æÖÆÍ¼Ïߣ¬Ôò°´ÕÕÉèÖõÄÑÕÉ«¸üÐÂͼÏß
        set(hculine,'color',color);
    end
end


% --- Executes on button press in chklun.
function chklun_Callback(hObject, eventdata, handles)
% hObject    handle to chklun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chklun

% ͼÏßµÄÏÔʾÒþ²Ø¸´Ñ¡¿ò
val = get(hObject,'Value');
hlunline = findobj(0,'tag','lunline');
if ~isempty(hlunline) % Èç¹ûÒѾ­»æÖÆÍ¼Ïß
    if val==1 % Èç¹ûÊÇÑ¡Öи´Ñ¡¿ò
        set(hlunline,'visible','on'); % ÏÔʾ
    else
        set(hlunline,'visible','off');
    end
    chkLegend_Callback(handles.chkLegend,[], handles); % ¸üÐÂͼÁÐ
end


% --- Executes on button press in chkCu.
function chkCu_Callback(hObject, eventdata, handles)
% hObject    handle to chkCu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chkCu

val = get(hObject,'Value');
hculine = findobj(0,'tag','culine');
if ~isempty(hculine)
    if val==1
        set(hculine,'visible','on');
    else
        set(hculine,'visible','off');
    end
    chkLegend_Callback(handles.chkLegend,[], handles)
end

% --- Executes on button press in chkJin.
function chkJin_Callback(hObject, eventdata, handles)
% hObject    handle to chkJin (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chkJin

val = get(hObject,'Value');
hjinline = findobj(0,'tag','jinline');
if ~isempty(hjinline)
    if val==1
        set(hjinline,'visible','on');
    else
        set(hjinline,'visible','off');
    end
    chkLegend_Callback(handles.chkLegend,[], handles)
end

% --- Executes on button press in chkLegend.
function chkLegend_Callback(hObject, eventdata, handles)
% hObject    handle to chkLegend (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chkLegend

% ͼÀý¸´Ñ¡¿òµÄ´¦Àí
val = get(hObject,'Value');

if val ==1 % Èç¹ûÑ¡Öи´Ñ¡¿ò
    hjinline = findobj(0,'tag','jinline');
    hculine = findobj(0,'tag','culine');
    hlunline = findobj(0,'tag','lunline');
   
    % ²âÊÔÊÇ·ñÒѾ­»æÖÆÇúÏß ²¢ÇÒÇúÏßÊÇ·ñ¿É¼û
    jflag = ~isempty(hjinline) & (get(handles.chkJin,'value'));
    cflag = ~isempty(hculine) & (get(handles.chkCu,'value'));
    lflag = ~isempty(hlunline) & (get(handles.chklun,'value'));
    warning off MATLABeprecatedLogicalAPI % ¹Ø±Õ¾¯¸æÐÅÏ¢£¬ÒòΪlflagµÈÊÇlogical£¬ÓÃnum2strÓо¯¸æ
    strflag = [num2str(lflag) num2str(cflag) num2str(jflag)];
   
    switch strflag
        case '111', % È«²¿
            legend([hlunline hculine hjinline],'ÍâÂÖÀªÏß','´Ö²å²¹µã','¾«²å²¹µã',2); % »æÖÆÍ¼Àý
        case '110' % ²»ÏÔʾ¾«²å²¹
            legend([hlunline hculine],'ÍâÂÖÀªÏß','´Ö²å²¹µã',2)
        case '101', % ²»ÏÔʾ´Ö²å²¹
            legend([hlunline hjinline],'ÍâÂÖÀªÏß','¾«²å²¹µã',2)
        case '011', % ²»ÏÔʾÂÖÀªÏß
            legend([hculine hjinline],'´Ö²å²¹µã','¾«²å²¹µã',2)
        case '100',
            legend(hlunline,'ÍâÂÖÀªÏß',2)
        case '001',
            legend(hjinline,'¾«²å²¹µã',2)
        case '010',
            legend(hculine,'´Ö²å²¹µã',2)  
        otherwise
            legend off % ͼÀý²»ÏÔʾ
    end
   
else
    legend off; % ͼÀý²»ÏÔʾ
end







% ²ÉÓõȽھàÎåµãÇóµ¼¹«Ê½µÄÖе㹫ʽÇóÊýֵ΢·Ö
% ÕâÀï´æÔÚÒ»¸öÎÊÌâÊÇ£¬Êýֵ΢·ÖµÄʱºò£¬hµ½µ×ÈçºÎѡȡ£¿
% ×Ô¶¯Ñ¡È¡µÄËã·¨ÊÇÔõôÑùµÄ£¿Èç¹ûÒª×Ô¶¯Ñ¡È¡£¬ËÙ¶ÈÈçºÎ£¿
function dr = drdtheta( fcnname,theta0)
%
h = 0.001;
theta_2 = theta0 - 2*h;
theta_1 = theta0 - h;
theta1 = theta0 + h;
theta2 = theta0 + 2*h;
theta = [theta_2 theta_1 theta1 theta2];
r = feval(fcnname,theta);
dr = 1/(12*h)*(r(1) - 8*r(2) + 8*r(3) - r(4));
8Â¥2015-11-30 19:42:54
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

ÍûÔÂÈÎ

гæ (СÓÐÃûÆø)

ÒýÓûØÌû:
7Â¥: Originally posted by onelightwang at 2015-11-30 19:20:48
Ìù´úÂë

function varargout = DemoGUI(varargin)
% DEMOGUI M-file for DemoGUI.fig
%      DEMOGUI, by itself, creates a new DEMOGUI or raises the existing
%      singleton*.
%
%      H = DEMOGUI returns the handle to a new DEMOGUI or the handle to
%      the existing singleton*.
%
%      DEMOGUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DEMOGUI.M with the given input arguments.
%
%      DEMOGUI('Property','Value',...) creates a new DEMOGUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before DemoGUI_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to DemoGUI_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help DemoGUI

% Last Modified by GUIDE v2.5 16-Apr-2005 18:42:13

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @DemoGUI_OpeningFcn, ...
                   'gui_OutputFcn',  @DemoGUI_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before DemoGUI is made visible.
function DemoGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to DemoGUI (see VARARGIN)

% Choose default command line output for DemoGUI
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes DemoGUI wait for user response (see UIRESUME)
% uiwait(handles.DemoFig);

% ÈÕÆÚʱ¼äÏÔʾ
set(handles.timestr,'string',datestr(now,0));
htimer = timer('StartDelay',1,'TimerFcn',...
    'htimestr=findall(0,''tag'',''timestr'');set(htimestr,''string'',datestr(now,0));',...
    'Period',1,'ExecutionMode','fixedSpacing','tag','showtime');
start(htimer);

set(hObject,'doublebuffer','on');



% --- Outputs from this function are returned to the command line.
function varargout = DemoGUI_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



% --- Executes on button press in ExitBtn.
function ExitBtn_Callback(hObject, eventdata, handles)
% hObject    handle to ExitBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

selection = questdlg(['Í˳ö ' get(handles.DemoFig,'Name') '?'],...
                     ['Í˳ö ' get(handles.DemoFig,'Name') '...'],...
                     'ÊÇ','·ñ','ÊÇ');
if strcmp(selection,'·ñ')
    return;
end
htimer = timerfind('tag','showtime');
stop(htimer);
delete(htimer);
delete(handles.DemoFig);

% --- Executes on button press in HelpBtn.
function HelpBtn_Callback(hObject, eventdata, handles)
% hObject    handle to HelpBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% str={'¶Ô²»Æð£¬Ä¿Ç°ÉÐδÍê³É˵Ã÷Îļþ';' ´òË㾡¿ìÍêÉÆÕû¸öϵͳ¹¦Äܼ°ÆäʹÓÃ˵Ã÷'};
% msgbox(str,'ʹÓðïÖú','help','non-modal');
!CNCHelp.CHM


% ¾«²å²¹°´Å¥»Øµ÷º¯Êý
% --- Executes on button press in JinBtn.
function JinBtn_Callback(hObject, eventdata, handles)
% hObject    handle to JinBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% »ñÈ¡ÉèÖõIJÎÊýÖµ
theta0 = get(handles.startRad,'UserData'); % ÍâÂÖÀªÆðʼµã¼«½Ç
thetat = get(handles.endRad,'UserData'); % ÍâÂÖÀªÖÐÖ¹µã¼«½Ç
interpTime = get(handles.interpT,'UserData'); % ²å²¹ÖÜÆÚ ms
mihuaNum = get(handles.miHuaNum,'UserData'); % ÃÜ»¯µãÊý
jinjiV = get(handles.jinjiV,'UserData'); % ½ø¸øËÙ¶È mm/min
jinjiV = jinjiV/60; % ½ø¸øËÙ¶Èmm/sec
clrjinline = get(handles.clrJin,'BackgroundColor'); % ¾«²åÖµµãÏßÑÕÉ«
% »ñÈ¡ÍâÂÖÀªº¯ÊýÃû
filename = get(handles.SelectFcnBtn,'UserData');
if isempty(filename)
    msgbox('ûÓÐѡȡÂÖÀªº¯Êý£¡','²Ù×÷´íÎó');
    return;
end
[pathstr,fcnname] = fileparts(filename); %»ñµÃÎļþÃûÓë·¾¶Ãû
% ÅжÏÊÇ˳Բ»¹ÊÇÄæÔ²²å²¹,ʵÏÖ²»¹Ü˳Բ»¹ÊÇÄæÔ²¶¼¿ÉÓ㨲»¹ýÖ»²âÊÔÁË˳Բ£­£­ÄæÊ±Õë²å²¹£©
if theta0>thetat    % ÄæÔ²
    flag = -1;
else           % ˳Բ
    flag = 1;
end
set(gcf,'doublebuffer','on');
axis(handles.axes2); % ÉèÖÃaxes2Ϊµ±Ç°×ø±êÖá
hjinline = line('color',clrjinline,'marker','.','markersize',4,...
                     'visible','off', 'tag','jinline'); % ´´½¨´Ö²åÖµÏß¶ÔÏó  
culinedata = getappdata(handles.CuBtn,'culinedata');  % »ñÈ¡´Ö²å²¹ÏßÊý¾Ý
cutheta = culinedata(:,1);  % ¼«½Ç
curho = culinedata(:,2); % ¼«¾¶
numCu = length(culinedata); % ´Ö²å²¹µãÊý
theta = [];
r = [];
set(hjinline,'visible','on');
outflag = 0;
% hbar = waitbar(0,'Please wait...','name','¾«²å²¹½øÐÐÖÐ');
for k = 1:numCu-1 % ¶Ôÿ¶Î´Ö²å²¹Çé¿ö
    tmptheta = cutheta(k); % theta0
    rr0 = curho(k); % rho0
    theta = [theta tmptheta];
    r = [r rr0];
    [xd,yd] = pol2cart(theta,r); % ¼«×ø±ê±ä³ÉÆ½ÃæÖ±½Ç×ø±ê
    set(hjinline,'xdata',xd,'ydata',yd);
    for n = 2:mihuaNum % ¼ÆËãÿ¶Î´Ö²å²¹ÖÐÃÜ»¯µã×ø±ê
        drda = drdtheta(fcnname,tmptheta); % ¼ÆËã¸ÃµãµÄÊýֵ΢·Ö
        deletatheta = interpTime/1000*jinjiV/(drda^2+rr0^2)^(0.5); % ¼ÆËãdeltatheta
        tmptheta = flag*deletatheta+tmptheta; % µü´úÇóÈ¡ÏÂÒ»¸ö¼«½Ç
        if flag*tmptheta>flag*cutheta(end) % ¶ÔÓÚ×îºóÒ»¶ÎµÄÌØÊâ´¦Àí,ÒòΪ×îºóÒ»¶Î¿ÉÄܱÈÒÔǰµÄ¶Ì
            tmptheta = cutheta(end); % ÊDz»Äܹ»²åÈënum¸öÃÜ»¯µãµÄ
            outflag = 1;
        end
        rr0 = feval(fcnname,tmptheta);
        theta = [theta tmptheta];
        r = [r rr0];
        [xd,yd] = pol2cart(theta,r);
        set(hjinline,'xdata',xd,'ydata',yd);
        if outflag==1
            break;  % ×îºóÒ»¶ÎÌØÊâ´¦ÀíÊ±Ìø³öÑ­»·
        end
    end
%     waitbar(k/(numCu-1),hbar);
end
% close(hbar);
theta = [theta cutheta(end)];
r = [r curho(end)];
jinlinedata = [theta( r(];
setappdata(hObject,'jinlinedata',jinlinedata); % ±£´æ¾«²å²¹ÏßÊý¾Ýµ½¾ä±úÖÐ
set(handles.chkJin,'enable','on'); % ʹµÃÏÔʾÒþ²ØÏ߸´Ñ¡¿ò¿ÉÓÃ
chkLegend_Callback(handles.chkLegend,[], handles);



% ´Ö²å²¹°´Å¥»Øµ÷º¯Êý
% --- Executes on button press in CuBtn.
function CuBtn_Callback(hObject, eventdata, handles)
% hObject    handle to CuBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% »ñÈ¡ÉèÖõIJÎÊýÖµ
theta0 = get(handles.startRad,'UserData'); % ÍâÂÖÀªÆðʼµã¼«½Ç
thetat = get(handles.endRad,'UserData'); % ÍâÂÖÀªÖÐÖ¹µã¼«½Ç
interpTime = get(handles.interpT,'UserData'); % ²å²¹ÖÜÆÚ ms
jinjiV = get(handles.jinjiV,'UserData'); % ½ø¸øËÙ¶È mm/min
jinjiV = jinjiV/60; % ½ø¸øËÙ¶Èmm/sec
clrlunline = get(handles.clrLun,'BackgroundColor'); % ÂÖÀªÏßÑÕÉ«
clrculine = get(handles.clrCu,'BackgroundColor'); % ´Ö²åÖµµãÏßÑÕÉ«

% »ñÈ¡ÍâÂÖÀªº¯ÊýÃû
filename = get(handles.SelectFcnBtn,'UserData');
if isempty(filename)
    msgbox('ûÓÐѡȡÂÖÀªº¯Êý£¡','²Ù×÷´íÎó');
    return;
end
[pathstr,fcnname] = fileparts(filename);
addpath(pathstr,'-begin');  % ½«ÍâÂÖÀªº¯ÊýËùÔÚ·¾¶¼ÓÈëmatlab·¾¶ÖÐ

set(handles.chklun,'enable','on'); % ʹ¸´Ñ¡¿ò¿ÉÓÃ
set(handles.chkLegend,'enable','on'); % ʹ¸´Ñ¡¿ò¿ÉÓÃ
set(handles.chkCu,'enable','on'); % ʹ¸´Ñ¡¿ò¿ÉÓÃ

% »æÖÆÍâÂÖÀªÏß
theta = linspace(theta0,thetat,1000);
r = feval(fcnname,theta); % ¼ÆËãÍâÂÖÀª
if length(r)~=length(theta)  % ͨ³£ÊÇÓÉÓÚÍâÂÖÀªº¯Êý²»¶ÔÔì³É
    msgbox('ÍâÂÖÀªº¯Êý´íÎó','³ö´íÁË...');
    return;
end
axis(handles.axes2);
hlunline = polar(theta,r);
set(hlunline,'color',clrlunline,'tag','lunline'); % ÉèÖÃtagÒÔºóºÃÓÃ
lundata = [theta( r(];
setappdata(hObject,'lundata',lundata); % ±£´æÂÖÀªÏßÊý¾Ýµ½¾ä±úÖÐ
hold on;
hculine = line('color',clrculine,'marker','.','markersize',10,...
                       'tag','culine'); % ´Ö²åÖµÏß¶ÔÏó  'erasemode','xor',
hold off;                 
theta = [];
r = [];
% ÅжÏÊÇ˳Բ»¹ÊÇÄæÔ²²å²¹,ʵÏÖ²»¹Ü˳Բ»¹ÊÇÄæÔ²¶¼¿ÉÓ㨲»¹ýÖ»²âÊÔÁË˳Բ£­£­ÄæÊ±Õë²å²¹£©
if theta0>thetat    % ÄæÔ²
    flag = -1;
else           % ˳Բ
    flag = 1;
end
tmptheta = theta0;
while flag*tmptheta<flag*thetat  % ÖÕÖ¹Åжϣ¬¿¼ÂÇÁË˳ԲÓëÄæÔ²
    rr0 = feval(fcnname,tmptheta); % ¼ÆËãÍâÂÖÀª¸Ã¼«½Ç³öµÄ¼«¾¶
    theta = [theta tmptheta];
    r = [r rr0];
    [xd,yd] = pol2cart(theta,r); % ת»»ÎªÖ±½Ç×ø±êϵÊýÖµ
    set(hculine,'xdata',xd,'ydata',yd); % ¸üвåÖµµã
    drda = drdtheta(fcnname,tmptheta); % ¼ÆËã¸Ã¼«½Ç´¦Êýֵ΢·Ö
    deletatheta = interpTime/1000*jinjiV/(drda^2+rr0^2)^(0.5);
    tmptheta = flag*deletatheta+tmptheta; % µü´úÇóÈ¡ÏÂÒ»¸öµã¼«½Ç
end
rr0 = feval(fcnname,thetat); % ÖÕµã¼ÓÈë
theta = [theta thetat];
r = [r rr0];
culinedata = [theta( r(];
setappdata(hObject,'culinedata',culinedata); % ±£´æ´Ö²å²¹ÏßÊý¾Ýµ½¾ä±úÖÐ

set(handles.ExportDataBtn,'enable','on');
set(handles.JinBtn,'enable','on');
chkLegend_Callback(handles.chkLegend,[], handles); % µ÷ÓÃͼÀý¸´Ñ¡¿òµÄ»Øµôº¯Êý

% --- Executes during object creation, after setting all properties.
function FcnName_CreateFcn(hObject, eventdata, handles)
% hObject    handle to FcnName (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end




% --- Executes on button press in SelectFcnBtn.
function SelectFcnBtn_Callback(hObject, eventdata, handles)
% hObject    handle to SelectFcnBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

[filename, pathname] = uigetfile('*.m', 'ѡȡÍâÂÖÀªÏßMÎļþ');
if filename~=0
    set(handles.FcnName,'string',filename);
    set(hObject,'UserData',[pathname filename]);
    set(handles.JinBtn,'enable','off');
    set(handles.ExportDataBtn,'enable','off');
    set(handles.chklun,'enable','off');
    set(handles.chkCu,'enable','off');
    set(handles.chkJin,'enable','off');
    set(handles.chkLegend,'value',0,'enable','off');
    axis(handles.axes2);
    cla
    chkLegend_Callback(handles.chkLegend,[], handles); % ¸üÐÂͼÁÐ
else
    set(handles.FcnName,'string','ÉÐδѡȡ');
end


% --- Executes on button press in ExportDataBtn.
function ExportDataBtn_Callback(hObject, eventdata, handles)
% hObject    handle to ExportDataBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% str={'¶Ô²»Æð£¬Ä¿Ç°ÉÐδÍê³É˵Ã÷Îļþ';' ´òË㾡¿ìÍêÉÆÕû¸öϵͳ¹¦Äܼ°ÆäʹÓÃ˵Ã÷'};
% msgbox(str,'ʹÓðïÖú','help','non-modal');

type = get(handles.dataType,'UserData'); % »ñÈ¡ÉèÖõĵ¼³öÊý¾Ý¸ñʽ 1-mat,2-txt,3-dat

% % »ñÈ¡¸÷ÖÖͼÏߵľä±ú
% hjinline = findobj(0,'tag','jinline');
% hculine = findobj(0,'tag','culine');
% hlunline = findobj(0,'tag','lunline');
% ±£´æÊ±
% % handles.CuBtn
% setappdata(hObject,'culinedata',culinedata); % ±£´æ´Ö²å²¹ÏßÊý¾Ýµ½¾ä±úÖÐ
% setappdata(hObject,'lundata',lundata); % ±£´æÂÖÀªÏßÊý¾Ýµ½¾ä±úÖÐ
% % handles.JinBtn
% setappdata(hObject,'jinlinedata',jinlinedata); % ±£´æ¾«²å²¹ÏßÊý¾Ýµ½¾ä±úÖÐ
lundata = getappdata(handles.CuBtn,'lundata');
culinedata = getappdata(handles.CuBtn,'culinedata');
jinlinedata = getappdata(handles.JinBtn,'jinlinedata');

switch type
    case 1,
        [filename, pathname] = uiputfile('*.mat', '±£´æ²å²¹½á¹û');
        if filename==0 % È¡Ïû
            return;
        end
        save([pathname filename],'lundata','culinedata','jinlinedata');
    case 2,
        [filename, pathname] = uiputfile('*.txt', '±£´æ²å²¹½á¹û');
        if filename==0
            return;
        end
        [pathstr,filename]=fileparts(filename);
        fid = fopen([pathname filename,'.txt'],'w');
        fprintf(fid,'\n£¥=================%s=================\r\n',datestr(now,0));
        fprintf(fid,'£¥Ô­Ê¼ÍâÂÖÀªÏßÊý¾Ý\r\n');
        fprintf(fid,'£¥ ¼«½Ç     \t   ¼«¾¶\r\n');
        fprintf(fid,'%8.6f  \t  %8.6f\r\n',lundata');
        fprintf(fid,'£¥´Ö²å²¹µãÊý¾Ý\r\n');
        fprintf(fid,'£¥ ¼«½Ç     \t   ¼«¾¶\r\n');
        fprintf(fid,'%8.6f  \t  %8.6f\r\n',culinedata');
        fprintf(fid,'£¥¾«²å²¹µãÊý¾Ý\r\n');
        fprintf(fid,'£¥ ¼«½Ç     \t   ¼«¾¶\r\n');
        fprintf(fid,'%8.6f  \t  %8.6f\r\n',jinlinedata');
        fclose(fid);   
    case 3,
        [filename, pathname] = uiputfile('*.dat', '±£´æ²å²¹½á¹û');
        if filename==0
            return;
        end
        [pathstr,filename]=fileparts(filename);
        save([pathname filename,'.dat'],'lundata','culinedata','jinlinedata','-ascii','-double');
    otherwise,
        msgbox('ÕÕµÀÀíÊDz»»á³öÏÖµÄ~');
end






% --- Executes on button press in ResetBtn.
function ResetBtn_Callback(hObject, eventdata, handles)
% hObject    handle to ResetBtn (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% ÉèÖø÷ÖÖ²ÎÊýΪĬÈÏÖµ
set(handles.startRad,'string','0','UserData',0);
set(handles.endRad,'string','2*pi','UserData',2*pi);
set(handles.miHuaNum,'string','4','UserData',4);
set(handles.interpT,'string','8','UserData',8);
set(handles.jinjiV,'string','4000','UserData',4000);
set(handles.clrLun,'BackgroundColor',[0 0 0]);
set(handles.clrCu,'BackgroundColor',[0 0 1]);
set(handles.clrJin,'BackgroundColor',[1 1 0.5]);
set(handles.dataType,'value',1,'UserData',1);
set(handles.chkLegend,'value',0,'UserData',0);


% --- Executes during object creation, after setting all properties.
function startRad_CreateFcn(hObject, eventdata, handles)
% hObject    handle to startRad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function startRad_Callback(hObject, eventdata, handles)
% hObject    handle to startRad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of startRad as text
%        str2double(get(hObject,'String')) returns contents of startRad as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data)  % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end


% --- Executes during object creation, after setting all properties.
function endRad_CreateFcn(hObject, eventdata, handles)
% hObject    handle to endRad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function endRad_Callback(hObject, eventdata, handles)
% hObject    handle to endRad (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of endRad as text
%        str2double(get(hObject,'String')) returns contents of endRad as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data) % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end



% --- Executes during object creation, after setting all properties.
function miHuaNum_CreateFcn(hObject, eventdata, handles)
% hObject    handle to miHuaNum (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function miHuaNum_Callback(hObject, eventdata, handles)
% hObject    handle to miHuaNum (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of miHuaNum as text
%        str2double(get(hObject,'String')) returns contents of miHuaNum as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data) % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end



% --- Executes during object creation, after setting all properties.
function interpT_CreateFcn(hObject, eventdata, handles)
% hObject    handle to interpT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function interpT_Callback(hObject, eventdata, handles)
% hObject    handle to interpT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of interpT as text
%        str2double(get(hObject,'String')) returns contents of interpT as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data) % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end



% --- Executes during object creation, after setting all properties.
function jinjiV_CreateFcn(hObject, eventdata, handles)
% hObject    handle to jinjiV (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end



function jinjiV_Callback(hObject, eventdata, handles)
% hObject    handle to jinjiV (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of jinjiV as text
%        str2double(get(hObject,'String')) returns contents of jinjiV as a double

str = get(hObject,'string');
data = str2num(str);
if isempty(data) % ÊäÈë²ÎÊýÓÐЧÐÔ¼ì²â
    errordlg('ÊäÈë±ØÐëΪÊýÖµ£¡','²ÎÊý´íÎó');
    set(hObject,'BackgroundColor','r');
else
    set(hObject,'BackgroundColor','w');
    set(hObject,'UserData',data);
end


% --- Executes during object creation, after setting all properties.
function dataType_CreateFcn(hObject, eventdata, handles)
% hObject    handle to dataType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end


% --- Executes on selection change in dataType.
function dataType_Callback(hObject, eventdata, handles)
% hObject    handle to dataType (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns dataType contents as cell array
%        contents{get(hObject,'Value')} returns selected item from dataType

% 1 - mat; 2 - txt ; 3 - dat
datatype = get(hObject,'Value');
set(hObject,'UserData',datatype);


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over clrLun.
function clrLun_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to clrLun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% ÑÕÉ«ÉèÖô¦Àí
color = uisetcolor;
if length(color)~=1 % Èç¹ûѡȡÁËÑÕÉ«
    set(hObject,'BackgroundColor',color);
    hlunline = findobj(0,'tag','lunline');
    if ~isempty(hlunline) % Èç¹ûÒÑ»æÖÆÍ¼Ïߣ¬Ôò°´ÕÕÉèÖõÄÑÕÉ«¸üÐÂͼÏß
        set(hlunline,'color',color);
    end
end

% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over clrJin.
function clrJin_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to clrJin (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

color = uisetcolor;
if length(color)~=1
    set(hObject,'BackgroundColor',color);
    hjinline = findobj(0,'tag','jinline');
    if ~isempty(hjinline) % Èç¹ûÒÑ»æÖÆÍ¼Ïߣ¬Ôò°´ÕÕÉèÖõÄÑÕÉ«¸üÐÂͼÏß
        set(hjinline,'color',color);
    end
end


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over clrCu.
function clrCu_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to clrCu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

color = uisetcolor;
if length(color)~=1
    set(hObject,'BackgroundColor',color);
    hculine = findobj(0,'tag','culine');
    if ~isempty(hculine) % Èç¹ûÒÑ»æÖÆÍ¼Ïߣ¬Ôò°´ÕÕÉèÖõÄÑÕÉ«¸üÐÂͼÏß
        set(hculine,'color',color);
    end
end


% --- Executes on button press in chklun.
function chklun_Callback(hObject, eventdata, handles)
% hObject    handle to chklun (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chklun

% ͼÏßµÄÏÔʾÒþ²Ø¸´Ñ¡¿ò
val = get(hObject,'Value');
hlunline = findobj(0,'tag','lunline');
if ~isempty(hlunline) % Èç¹ûÒѾ­»æÖÆÍ¼Ïß
    if val==1 % Èç¹ûÊÇÑ¡Öи´Ñ¡¿ò
        set(hlunline,'visible','on'); % ÏÔʾ
    else
        set(hlunline,'visible','off');
    end
    chkLegend_Callback(handles.chkLegend,[], handles); % ¸üÐÂͼÁÐ
end


% --- Executes on button press in chkCu.
function chkCu_Callback(hObject, eventdata, handles)
% hObject    handle to chkCu (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chkCu

val = get(hObject,'Value');
hculine = findobj(0,'tag','culine');
if ~isempty(hculine)
    if val==1
        set(hculine,'visible','on');
    else
        set(hculine,'visible','off');
    end
    chkLegend_Callback(handles.chkLegend,[], handles)
end

% --- Executes on button press in chkJin.
function chkJin_Callback(hObject, eventdata, handles)
% hObject    handle to chkJin (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chkJin

val = get(hObject,'Value');
hjinline = findobj(0,'tag','jinline');
if ~isempty(hjinline)
    if val==1
        set(hjinline,'visible','on');
    else
        set(hjinline,'visible','off');
    end
    chkLegend_Callback(handles.chkLegend,[], handles)
end

% --- Executes on button press in chkLegend.
function chkLegend_Callback(hObject, eventdata, handles)
% hObject    handle to chkLegend (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of chkLegend

% ͼÀý¸´Ñ¡¿òµÄ´¦Àí
val = get(hObject,'Value');

if val ==1 % Èç¹ûÑ¡Öи´Ñ¡¿ò
    hjinline = findobj(0,'tag','jinline');
    hculine = findobj(0,'tag','culine');
    hlunline = findobj(0,'tag','lunline');
   
    % ²âÊÔÊÇ·ñÒѾ­»æÖÆÇúÏß ²¢ÇÒÇúÏßÊÇ·ñ¿É¼û
    jflag = ~isempty(hjinline) & (get(handles.chkJin,'value'));
    cflag = ~isempty(hculine) & (get(handles.chkCu,'value'));
    lflag = ~isempty(hlunline) & (get(handles.chklun,'value'));
    warning off MATLABeprecatedLogicalAPI % ¹Ø±Õ¾¯¸æÐÅÏ¢£¬ÒòΪlflagµÈÊÇlogical£¬ÓÃnum2strÓо¯¸æ
    strflag = [num2str(lflag) num2str(cflag) num2str(jflag)];
   
    switch strflag
        case '111', % È«²¿
            legend([hlunline hculine hjinline],'ÍâÂÖÀªÏß','´Ö²å²¹µã','¾«²å²¹µã',2); % »æÖÆÍ¼Àý
        case '110' % ²»ÏÔʾ¾«²å²¹
            legend([hlunline hculine],'ÍâÂÖÀªÏß','´Ö²å²¹µã',2)
        case '101', % ²»ÏÔʾ´Ö²å²¹
            legend([hlunline hjinline],'ÍâÂÖÀªÏß','¾«²å²¹µã',2)
        case '011', % ²»ÏÔʾÂÖÀªÏß
            legend([hculine hjinline],'´Ö²å²¹µã','¾«²å²¹µã',2)
        case '100',
            legend(hlunline,'ÍâÂÖÀªÏß',2)
        case '001',
            legend(hjinline,'¾«²å²¹µã',2)
        case '010',
            legend(hculine,'´Ö²å²¹µã',2)  
        otherwise
            legend off % ͼÀý²»ÏÔʾ
    end
   
else
    legend off; % ͼÀý²»ÏÔʾ
end







% ²ÉÓõȽھàÎåµãÇóµ¼¹«Ê½µÄÖе㹫ʽÇóÊýֵ΢·Ö
% ÕâÀï´æÔÚÒ»¸öÎÊÌâÊÇ£¬Êýֵ΢·ÖµÄʱºò£¬hµ½µ×ÈçºÎѡȡ£¿
% ×Ô¶¯Ñ¡È¡µÄËã·¨ÊÇÔõôÑùµÄ£¿Èç¹ûÒª×Ô¶¯Ñ¡È¡£¬ËÙ¶ÈÈçºÎ£¿
function dr = drdtheta( fcnname,theta0)
%
h = 0.001;
theta_2 = theta0 - 2*h;
theta_1 = theta0 - h;
theta1 = theta0 + h;
theta2 = theta0 + 2*h;
theta = [theta_2 theta_1 theta1 theta2];
r = feval(fcnname,theta);
dr = 1/(12*h)*(r(1) - 8*r(2) + 8*r(3) - r(4));
9Â¥2015-11-30 19:43:42
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû

ÍûÔÂÈÎ

гæ (СÓÐÃûÆø)

Ëͺ컨һ¶ä
ÒýÓûØÌû:
7Â¥: Originally posted by onelightwang at 2015-11-30 19:20:48
Ìù´úÂë

Ö±½Ó¸ø´úÂë»áÓÐÂÒÂ룬¸øÄ㸽¼þ°É£¬Ð»Ð»

» ±¾Ìû¸½¼þ×ÊÔ´Áбí

  • »¶Ó­¼à¶½ºÍ·´À¡£ºÐ¡Ä¾³æ½öÌṩ½»Á÷ƽ̨£¬²»¶Ô¸ÃÄÚÈݸºÔð¡£
    ±¾ÄÚÈÝÓÉÓû§×ÔÖ÷·¢²¼£¬Èç¹ûÆäÄÚÈÝÉæ¼°µ½ÖªÊ¶²úȨÎÊÌ⣬ÆäÔðÈÎÔÚÓÚÓû§±¾ÈË£¬Èç¶Ô°æÈ¨ÓÐÒìÒ飬ÇëÁªÏµÓÊÏ䣺xiaomuchong@tal.com
  • ¸½¼þ 1 : DemoGUI.m
  • 2015-11-30 19:45:12, 27.36 K
10Â¥2015-11-30 19:46:03
ÒÑÔÄ   »Ø¸´´ËÂ¥   ¹Ø×¢TA ¸øTA·¢ÏûÏ¢ ËÍTAºì»¨ TAµÄ»ØÌû
Ïà¹Ø°æ¿éÌø×ª ÎÒÒª¶©ÔÄÂ¥Ö÷ ÍûÔÂÈÎ µÄÖ÷Ìâ¸üÐÂ
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] ²ÄÁÏר˶306Ó¢Ò»Êý¶þ +4 z1z2z3879 2026-03-16 4/200 2026-03-16 13:53 by laoshidan
[¿¼ÑÐ] 0703 ÎïÀí»¯Ñ§µ÷¼Á +3 ÎÒ¿ÉÒÔÉϰ¶µÄ¶Ô 2026-03-13 5/250 2026-03-16 10:50 by ÎÒ¿ÉÒÔÉϰ¶µÄ¶ÔÂ
[¿¼ÑÐ] 297Ò»Ö¾Ô¸ÉϽ»085600Çóµ÷¼Á +5 Ö¸¼â°ËǧÀï 2026-03-14 5/250 2026-03-14 17:26 by a²»Ò×
[¿¼ÑÐ] Ò»Ö¾Ô¸¹þ¹¤´ó²ÄÁÏ324·ÖÇóµ÷¼Á +5 ãÆÐñ¶« 2026-03-14 5/250 2026-03-14 14:53 by ľ¹Ï¸à
[¿¼ÑÐ] 330Çóµ÷¼Á +3 ?½´¸øµ÷¼Á¹òÁË 2026-03-13 3/150 2026-03-14 10:13 by JourneyLucky
[¿¼ÑÐ] 341Çóµ÷¼Á +4 ·¬ÇÑÍ·--- 2026-03-10 4/200 2026-03-13 23:12 by JourneyLucky
[¿¼ÑÐ] 341Çóµ÷¼Á +3 ·¬ÇÑÍ·--- 2026-03-10 3/150 2026-03-13 23:07 by JourneyLucky
[¿¼ÑÐ] Çóµ÷¼Á£¨²ÄÁÏÓ뻯¹¤327£© +4 °®³ÔÏã²ËÀ² 2026-03-11 4/200 2026-03-13 22:11 by JourneyLucky
[¿¼ÑÐ] 336Çóµ÷¼Á +6 Iuruoh 2026-03-11 6/300 2026-03-13 22:06 by JourneyLucky
[¿¼ÑÐ] ²ÄÁÏÓ뻯¹¤085600µ÷¼ÁÇóÀÏʦÊÕÁô +9 jiaanl 2026-03-11 9/450 2026-03-13 20:22 by JourneyLucky
[¿¼ÑÐ] ¡¾¿¼Ñе÷¼ÁÇóÊÕÁô¡¿ +3 Ceciilia 2026-03-11 3/150 2026-03-13 20:18 by JourneyLucky
[¿¼ÑÐ] 302Çóµ÷¼Á +6 ¸ºÐÄÕßµ±Öï 2026-03-11 6/300 2026-03-13 16:11 by JourneyLucky
[¿¼ÑÐ] 295Çóµ÷¼Á +3 Сذ×ÐÖ­ 2026-03-12 3/150 2026-03-13 15:17 by vgtyfty
[¿¼ÑÐ] һ־Ըɽ´ó07»¯Ñ§ 332·Ö ËÄÁù¼¶Òѹý ±¾¿ÆÉ½¶«Ë«·Ç Çóµ÷¼Á£¡ +3 ²»ÏëÀíÄã 2026-03-12 3/150 2026-03-13 14:18 by JourneyLucky
[¿¼ÑÐ] 289Çóµ÷¼Á +3 ÀîÕþÓ¨ 2026-03-12 3/150 2026-03-13 11:02 by Çóµ÷¼Ázz
[¿¼ÑÐ] 081200-11408-276ѧ˶Çóµ÷¼Á +3 ´Þwj 2026-03-12 4/200 2026-03-12 19:33 by Çóµ÷¼Ázz
[¿¼²©] 2026Ä격ʿÉêÇë +3 QwQwQW10 2026-03-11 3/150 2026-03-12 17:58 by gxch43
[¿¼ÑÐ] 298Çóµ÷¼Á +3 Vvѽ£¡ 2026-03-10 3/150 2026-03-10 22:40 by ½£Ê«¶Å¿µ
[¿¼ÑÐ] 0856²ÄÁÏÓ뻯¹¤353·ÖÇóµ÷¼Á +11 NIFFFfff 2026-03-09 11/550 2026-03-10 18:36 by suyuanhai
[¿¼ÑÐ] 085602»¯¹¤Çóµ÷¼Á +7 ¶­boxing 2026-03-10 7/350 2026-03-10 17:07 by BruceLiu320
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û