Matlab intro powerpo..

advertisement
Introduction to MATLAB
for Biomedical Engineering
BME 1008 Introduction to Biomedical Engineering
FIU, Spring 2015
Instructor (Matlab)
Adam Kapela, Ph.D.
akapela@fiu.edu
Learning Assistants (LA's)
Karla Montejo kmont057@fiu.edu
Elizabeth Solis esoli005@fiu.edu
Teresa Milan tmila002@fiu.edu
Christina Moya cmoya007@fiu.edu
Computing in BME
 Data analysis and visualization, parameter estimation
 Signal processing, feature extraction
ECG
 Image Reconstruction and Analysis
MRI
 Modeling and Simulations
 And more ...
Heart
Model
MATLAB (matrix laboratory)
 Programming language and software environment
for technical and scientific computing.
 MATLAB allows
 matrix manipulations,
 plotting of functions and data,
 implementation of algorithms,
 creation of user interfaces.
Matlab toolboxes
 Statistics Toolbox
 Signal Processing Toolbox
 Image Processing Toolbox
 Bioinformatics Toolbox
 SimBiology
 Data Acquisition Toolbox (laboratory exercise)
 and more ...
Schedule
 Week 2
 Introduction to Matlab, Basic commands and functions
 Week 3
 Reading/writing data files, Visualizing data
 Week 4
 Basics of Analog-to-Digital conversion,
 Week 5
 National Instruments AD/DA converter
 Week 7
 Data Aqusition Toolbox
 Test (21% of total grade)
Access to Matlab
 Developed and sold by MathWorks, MA
 FIU
 Connect from anywhere through Citrix


elabs.fiu.edu (elabs.fiu.edu/Citrix/GetStarted.pdf )
EIC apps (eic.fiu.edu/apps/)
 Computer labs (Engineering Center)
 HPC Panther Cluster (research only)
 Student licence: $50, MATLAB Suite $99, Add-On
Products $29
Free alternatives to Matlab
 SciLab
 excellent for standard computations and plotting
 easy installation
 not fully compatible with Matlab
 less toolboxes
 GNU Octave
 syntax mostly compatible with Matlab
 hard installation, GUI unofficial
Matlab environment
Workspace
window
>> command prompt
Command window
Command
history
Elements of Matlab language
>> % This is Matlab Comment
>>
 Basic operations:
>> 3.67 + 4 - 3.67^3
ans =
-41.7609
+ addition, - subtraction, * multiplication, / division, ^ power
>> ((3.67+7)*10)^2 %()operator precedence
 Variable - a named storage for information (numbers
or text)
 variable name must start with a letter
>> x = 3.67
% = assignment operator
>> x + 4 - x^3
>> ((x+7)*10)^2
ans =
-41.7609
 ans - automatic variable that stores most recent result
 variables can store text strings
>> s1 = 'time'
%string variable
s1 =
time
>> s2 = '(seconds)'
s2 =
(second)
>> s = [s1 s2]
%string concatenation
s=
time (seconds)
 Variable names are case sensitive
>> a1 = 0.00025
>> A1 = 10^5
>> b = A1 * a1
% = 2.5e-4
% = 1e5
% = 25
 "Scientific notation" - "10^" replaced by "e"
10^7 = 1e7
2.15*10^-3 = 2.15e-3.
 "e" does not mean the Euler's number
 exp(1) = 2.71... (Euler's number)
 Scalar
>> x = 5
 Vector (1 dimensional array)
>> vr = [10 20 30] % row vector
vr =
10 20 30
>> vc = [-5 10 1/5]' % ' transpose operator
vc =
% column vector
-5
10
0.2
 Vectors can store 1-dimesional signals
 Matrix (2 dimensional array)
>> A=[1 2 3; 4 5 6] %2-by-3 matrix
A =
1
2
3
4
5
6
>> B=[1
B =
1
3
5
2; 3 4; 5 6] %3-by-2 matrix
2
4
6
 Matrices can store images
 Managing commands
>> whos %List current variables
>> clear
%Removes items from workspace
and memory
>> clc %clears command window, keeps variables
>> a = 2; b = 2^16;
%semicolon (;) terminates a
command and prevents
displaying result
>> help %lists all primary help topics and toolboxes
>> help sqrt %square root
>> lookfor 'square root' %search matlab directories
%for keywords
 When looking for help, try also
 offline and online Matlab documentation
 Just Google "Matlab square root" !
Basic functions
>> A = [0 1 -2 20 30 20];
%vector
>> mean(A) %mean (average)
>> ans =
11.5
>> maxA = max(A) %maximum value
>> maxA =
30
>> minA = min(A) %minimum value
>> minA =
-2
 Mean from a matrix
>> A = [0 1 -2; 20 30 20] %2-by-3 matrix
A =
0
1
-2
20
30
20
>> mean(A) %mean(A,1) - mean along dimension 1
ans =
10.0000
15.5000
9.0000
>> M2 = mean(A,2) %mean along dimension 2
M2 =
-0.3333
23.3333
 Max from a matrix
>> A = [0 1 -2; 20 30 20] %2-by-3 matrix
A =
0
1
-2
20
30
20
>> max(A) %or max(A,[],1) - max along dimension 1
ans =
20
30
20
>> M2 = max(A,[],2) %max along dimension 2
M2 =
1
30
>> A = [0 1 -2 20 30 20];
%vector
>> std(A) %standard deviation
ans =
13.5
>> B = [-2 5 4i 3+4i] %vector with complex
numbers
>> m = abs(B) %absolute value (magnitude)
m =
2
5
4
5
Download