⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 de.m

📁 matlab中用于解决微分方程问题的GUI程序
💻 M
字号:
function varargout = de(varargin)
%CREATED BY H.N.P MORAGASPITIYA (PRAVEENENG@HOTMAIL.COM)
% de M-file for de.fig
%      de, by itself, creates a new de or raises the existing
%      singleton*.
%
%      H = de returns the handle to a new de or the handle to
%      the existing singleton*.
%
%      de('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in de.M with the given input arguments.
%
%      de('Property','Value',...) creates a new de or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before de_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to de_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 de

% Last Modified by GUIDE v2.5 05-May-2006 13:40:56
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @de_OpeningFcn, ...
                   'gui_OutputFcn',  @de_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 de is made visible.
function de_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 de (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes de wait for user response (see UIRESUME)
% uiwait(handles.figure1);
%im=imread('praveen.jpg');
%axes(handles.image);
%set(handles.image,'UserData',image(im));
%figure('doublebuffer','on');
%m=aviread('praveen.avi');
%get(gct,'doubleBuffer');
%set(m,'doubleBuffer','on');
im=imread('praveen.jpg');
axes(handles.image);
axis off;
set(handles.image,'UserData',image(im));


% --- Outputs from this function are returned to the command line.
function varargout = de_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 during object creation, after setting all properties.function m_CreateFcn(hObject, eventdata, handles)% hObject    handle to m (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'));endfunction m_Callback(hObject, eventdata, handles)% hObject    handle to m (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 m as text%        str2double(get(hObject,'String')) returns contents of m as a double% --- Executes during object creation, after setting all properties.function c_CreateFcn(hObject, eventdata, handles)% hObject    handle to c (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'));endfunction c_Callback(hObject, eventdata, handles)% hObject    handle to c (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 c as text%        str2double(get(hObject,'String')) returns contents of c as a double% --- Executes during object creation, after setting all properties.function k_CreateFcn(hObject, eventdata, handles)% hObject    handle to k (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'));endfunction k_Callback(hObject, eventdata, handles)% hObject    handle to k (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 k as text%        str2double(get(hObject,'String')) returns contents of k as a double% --- Executes during object creation, after setting all properties.function u_CreateFcn(hObject, eventdata, handles)% hObject    handle to u (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'));endfunction u_Callback(hObject, eventdata, handles)% hObject    handle to u (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 u as text%        str2double(get(hObject,'String')) returns contents of u as a double% --- Executes during object creation, after setting all properties.function u0_CreateFcn(hObject, eventdata, handles)% hObject    handle to u0 (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'));endfunction u0_Callback(hObject, eventdata, handles)% hObject    handle to u0 (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 u0 as text%        str2double(get(hObject,'String')) returns contents of u0 as a double% --- Executes on button press in Calculate.function Calculate_Callback(hObject, eventdata, handles)% hObject    handle to Calculate (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)global m;
global k;
global c;
global u;
global u0;
global wd;
global neta;
global x;

m=str2double(get(handles.m,'string'));
k=str2double(get(handles.k,'string'));c=str2double(get(handles.c,'string'));u=str2double(get(handles.u,'string'));
u0=str2double(get(handles.u0,'string'));
if m<=0 
    errordlg('Please input valid value for Mass','error','modal');
end

if k<=0
errordlg('Please input valid value for Stiffness','error','modal');
end



wd=(k/m)^0.5;
neta=c/(2.*(m.*k)^0.5);
wdd=sprintf('%0.2f',wd);
netaa=sprintf('%0.2f',neta);
set(handles.wd,'string',wdd);
set(handles.neta,'string',netaa);


t=[0:0.01:100];    
if neta==1
    set(handles.dis,'string','CRITICAL DAMPING');
    a=u-1;
    b=u0+neta.*wd.*a-neta.*wd;
    x=1+a.*(2.72.^(-neta.*wd.*t))+b.*t.*(2.72.^(-neta.*wd.*t));
    axes(handles.axes);
    plot(t,x,'r');
    
    
    %for i = 1:1000
    %m = x(1,i);
    %imx=[2 3 3 2];
    %imy=[2+m 2+m 3+m 3+m];
    %axes(handles.image);
    %plot(imx,imy);
    %pause(.5);
    %end
    
    
    
    
    
    
    
    
    
elseif neta>1
    set(handles.dis,'string','OVERDAMPING');
    a=(1+wd.*(neta+(neta.^2-1).^0.5).*(u-1)+u0)/(2.*wd.*(neta.^2-1).^0.5);
    b=(u0+wd.*(neta-(neta.^2-1).^0.5).*(u-1))/(2.*wd.*(neta.^2-1).^0.5);
    x=1+a.*2.72.^(-wd.*(neta-(neta.^2-1).^0.5).*t)+b.*2.72.^(-wd.*(neta+(neta.^2-1).^0.5).*t);
    axes(handles.axes);
    plot(t,x,'r');
           
 
elseif neta<1
    set(handles.dis,'string','UNDERDAMPING');
    a=u-1;
    b=(u0+neta.*wd.*(u-1))/(wd.*(1-neta.^2).^0.5);
    x=1+2.72.^(-neta.*wd.*t).*(a.*cos((wd.*(1-neta.^2).^0.5).*t)+b.*sin((wd.*(1-neta.^2).^0.5).*t));
    axes(handles.axes);
    plot(t,x,'r');
    
        
end    
%clear all;


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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -