Lecture 15 - Introduction to Matrix Programming
Lecture 15 - Introduction to Matrix Programming
TO MATRIX
PROGRAMMING
Calvin Kuo
BMEG 257, CLASS 15, 03/04/2025
CLASS OUTLINE
• Matrix programming
• Overview of computer programming
• Practical programming for data analysis
• How to represent data in code
2
PROGRAMMING LANGUAGES
3
PROGRAMMING LANGUAGES
4
POPULAR LANGUAGES AND THEIR PROS / CONS
Python Java
• Scripting language • Compile language
• Easy to write • Packaged for transportability
• Easy to run • Bulky applications
• Slow and inefficient • Less control for optimization
C/C++
Matlab, R
• Compile language
• Scripting language
• Offers full control for
• Optimized specifically for
optimization / speed
numerical computations
• Difficult to master
5
DO YOU NEED TO ONLY USE ONE LANGUAGE?
Sensor Firmware: C
Maximum memory and speed
efficiency
7
WHAT IS DATA?
Descriptive
Numerical
DATA = INFORMATION
1 2 3
𝐴𝐴 = 2 rows 𝐴𝐴 is a 2 × 3 matrix
4 5 6
columns
• Generalizes to fewer dimensions
• 1-dimension matrix is a vector
• 0-dimension matrix is a scalar
• Generalizes to more dimensions
• 𝑛𝑛1 × 𝑛𝑛2 × 𝑛𝑛3 × ⋯ with each 𝑛𝑛𝑖𝑖 referring to the number of elements
in dimension 𝑖𝑖 9
EXAMPLE: TIME SERIES DATA
Option 1 Option 2
Simultaneous Measurement Separate Matrices
Time Temp 1 Pressure
⋮ ⋮ ⋮ ⋮ ⋮ ⋮ 11
EXAMPLE: SURVEY DATA
6. Neck examination
findings: 13
EXAMPLE: SURVEY DATA
6. Neck examination
findings: 15
EXAMPLE: IMAGES
⋮ ⋱
356 pixels
… …
Create a 1 2 3
𝐴𝐴 = A = [1, 2, 3; 4, 5, 6] A = numpy.array([[1, 2, 3], [4, 5, 6]])
matrix 4 5 6
20
CLASS RECAP
Next time
• How do we store this data?
21
THANKS!