Codes for GUI:
Codes for GUI:
function varargout = BME301GUI(varargin)
% BME301GUI MATLAB code for BME301GUI.mov
% BME301GUI, by itself, creates a new BME301GUI or raises the existing
% singleton*.
%
% H = BME301GUI returns the handle to a new BME301GUI or the handle to
% the existing singleton*.
%
% BME301GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BME301GUI.M with the given input arguments.
%
% BME301GUI('Property','Value',...) creates a new BME301GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before BME301GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to BME301GUI_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 BME301GUI
% Last Modified by GUIDE v2.5 11-May-2011 11:47:52
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @BME301GUI_OpeningFcn, ...
'gui_OutputFcn', @BME301GUI_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 BME301GUI is made visible.
function BME301GUI_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 BME301GUI (see VARARGIN)
% Choose default command line output for BME301GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes BME301GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = BME301GUI_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 Play.
function Play_Callback(hObject, eventdata, handles)
% hObject handle to Play (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Pc = handles.InputB;
g = [1:-0.05:Pc];
z = zeros(100000,length(g));
i = 1;
while i <= length(g)
[ti, vt] = LR1M(1000, g(i));
z(:, i) = vt;
i = i + 1;
end
for n = 1:(length(g))
plot(ti, z(:,n)); axis([0 1000 -100 50]);
xlabel('Time (ms)'); ylabel('Transmembrane Voltage (mV)');
M(:,n) = getframe;
end
moviereps = -5; % number of repetitions of the movie
speedratio = 10; % ratio of movie speed to actual speed
handles.Fig = M;
movie(handles.Fig,moviereps,speedratio)
guidata(hObject, handles);
function InputB_Callback(hObject, eventdata, handles)
% hObject handle to InputB (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 InputB as text
% str2double(get(hObject,'String')) returns contents of InputB as a double
handles.InputB = str2num(get(hObject,'String'))*0.01;
if(isempty(handles.InputB))
set(hObject,'String','0')
end
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function InputB_CreateFcn(hObject, eventdata, handles)
% hObject handle to InputB (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
% --- Executes on button press in plot.
function plot_Callback(hObject, eventdata, handles)
% hObject handle to plot (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[time, voltage] = LR1M(1000, handles.InputB);
handles.Fig = plot(time, voltage);
axis([0 1000 -100 50]);
xlabel('Time (ms)')
ylabel('Transmembrane Voltage (mV)')
guidata(hObject,handles);
% --- Executes on button press in Save.
function Save_Callback(hObject, eventdata, handles)
% hObject handle to Save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[file_name, path_name] = uiputfile({ '*.png','PNG File (*.png)';...
'*.bmp','Bitmap (*.bmp)'; '*.fig','Figure (*.fig)'}, ...
'Save picture as','default');
if isequal(file_name,0) || isequal(path_name,0)
return
end
% --- 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
Categories:
MATLAB