Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

gerryliyana Group Title

Graphical Damped Osccilation System by using Graphical User Interface (GUI) on MATLAB, check it out

  • one year ago
  • one year ago

  • This Question is Closed
  1. gerryliyana Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    function varargout = osilasi(varargin) % OSILASI MATLAB code for osilasi.fig % OSILASI, by itself, creates a new OSILASI or raises the existing % singleton*. % % H = OSILASI returns the handle to a new OSILASI or the handle to % the existing singleton*. % % OSILASI('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in OSILASI.M with the given input arguments. % % OSILASI('Property','Value',...) creates a new OSILASI or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before osilasi_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to osilasi_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 osilasi % Last Modified by GUIDE v2.5 08-Jan-2013 11:29:53 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @osilasi_OpeningFcn, ... 'gui_OutputFcn', @osilasi_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 osilasi is made visible. function osilasi_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 osilasi (see VARARGIN) % Choose default command line output for osilasi handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes osilasi wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = osilasi_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 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 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')); end function 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 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')); end function 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 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')); end function 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 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')); end function 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 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')); end % --- 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;

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.