【氣動學】基於matlab GUI龍格庫塔演算法外彈道模擬【含Matlab原始碼 1053期】
阿新 • • 發佈:2021-06-24
一、簡介
二、原始碼
%%%%%%%%%%%%%%%%%%%%function pushbutton_fangzhen_Callback(hObject, %%%%%%%%%%%%%%%%%%%%eventdata, handles)主程式所在函式 function varargout = graduate(varargin) % GRADUATE MATLAB code for graduate.fig % GRADUATE, by itself, creates a new GRADUATE or raises the existing % singleton*. % % H = GRADUATE returns the handle to a new GRADUATE or the handle to % the existing singleton*. % % GRADUATE('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in GRADUATE.M with the given input arguments. % % GRADUATE('Property','Value',...) creates a new GRADUATE or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before graduate_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to graduate_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 graduate % Last Modified by GUIDE v2.5 12-Jun-2021 10:34:42 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @graduate_OpeningFcn, ... 'gui_OutputFcn', @graduate_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(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 graduate is made visible. function graduate_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 graduate (see VARARGIN) global simVars simVars.Track=0; simVars.Tra=0; simVars.data_number=0; simVars.H_point=0; simVars.L_point=0; simVars.AC_point=0; % Choose default command line output for graduate handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes graduate wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = graduate_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; function txt_hengfeng_Callback(hObject, eventdata, handles) % hObject handle to txt_hengfeng (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 txt_hengfeng as text % str2double(get(hObject,'String')) returns contents of txt_hengfeng as a double global simVars simVars.Wx=str2double(get(hObject,'string')); if isnan(simVars.Wx) set(hObject,'String',''); errordlg('請輸入數字','Bad Input','modal') end % --- Executes during object creation, after setting all properties. function txt_hengfeng_CreateFcn(hObject, eventdata, handles) % hObject handle to txt_hengfeng (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function txt_zongfeng_Callback(hObject, eventdata, handles) % hObject handle to txt_zongfeng (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 txt_zongfeng as text % str2double(get(hObject,'String')) returns contents of txt_zongfeng as a double global simVars simVars.Wz=str2double(get(hObject,'string')); if isnan(simVars.Wz) set(hObject,'String',''); errordlg('請輸入數字','Bad Input','modal') end % --- Executes during object creation, after setting all properties. function txt_zongfeng_CreateFcn(hObject, eventdata, handles) % hObject handle to txt_zongfeng (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function txt_shexiangjiao_Callback(hObject, eventdata, handles) % hObject handle to txt_shexiangjiao (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 txt_shexiangjiao as text % str2double(get(hObject,'String')) returns contents of txt_shexiangjiao as a double global simVars simVars.alpha=str2double(get(hObject,'string')); if isnan(simVars.alpha) set(hObject,'String',''); errordlg('請輸入數字','Bad Input','modal') end % --- Executes during object creation, after setting all properties. function txt_shexiangjiao_CreateFcn(hObject, eventdata, handles) % hObject handle to txt_shexiangjiao (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function txt_weidu_Callback(hObject, eventdata, handles) % hObject handle to txt_weidu (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 txt_weidu as text % str2double(get(hObject,'String')) returns contents of txt_weidu as a double global simVars simVars.lambda=str2double(get(hObject,'string')); if isnan(simVars.lambda) set(hObject,'String',''); errordlg('請輸入數字','Bad Input','modal') end % --- Executes during object creation, after setting all properties. function txt_weidu_CreateFcn(hObject, eventdata, handles) % hObject handle to txt_weidu (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function txt_caiyang_Callback(hObject, eventdata, handles) % hObject handle to txt_caiyang (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 txt_caiyang as text % str2double(get(hObject,'String')) returns contents of txt_caiyang as a double global simVars simVars.h=str2double(get(hObject,'string')); if isnan(simVars.h) set(hObject,'String',''); errordlg('請輸入數字','Bad Input','modal') end % --- Executes during object creation, after setting all properties. function txt_caiyang_CreateFcn(hObject, eventdata, handles) % hObject handle to txt_caiyang (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end function txt_konggao_Callback(hObject, eventdata, handles) % hObject handle to txt_konggao (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 txt_konggao as text % str2double(get(hObject,'String')) returns contents of txt_konggao as a double global simVars simVars.ctrl_h=str2double(get(hObject,'string')); if isnan(simVars.ctrl_h) set(hObject,'String',''); errordlg('請輸入數字','Bad Input','modal') end % --- Executes during object creation, after setting all properties. function txt_konggao_CreateFcn(hObject, eventdata, handles) % hObject handle to txt_konggao (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end
三、執行結果
四、備註
版本:2014a