A comprehensive, hands-on introduction to MATLAB programming. This repository contains 11 progressive lessons covering everything from basic commands to array manipulation ā the essential building blocks for scientific computing, data analysis, and engineering with MATLAB.
- About
- Prerequisites
- Lessons
- Quick Start
- Topics Covered
- File Structure
- Key Concepts Summary
- Contributing
- License
This tutorial series was designed for beginners who want to learn MATLAB from scratch. Each lesson is a self-contained .m script file with detailed comments explaining every concept. The lessons build progressively ā start from Lesson 01 and work through sequentially for the best learning experience.
- MATLAB (any recent version: R2020a or later recommended)
- Or GNU Octave (free alternative, compatible with most examples)
- No prior programming experience required
| # | Lesson | File | Description |
|---|---|---|---|
| 01 | Basic Commands | lesson_01_commands.m |
Command Window, arithmetic, assigning variables |
| 02 | Naming Variables | lesson_02_variables.m |
Variable naming rules, case sensitivity |
| 03 | Save & Load | lesson_03_save_load.m |
Saving/loading workspace data to .mat files |
| 04 | Built-in Functions | lesson_04_builtin_functions.m |
sin, sqrt, abs, exp, constants |
| 05 | Scripts | lesson_05_scripts.m |
Creating and running .m script files |
| 06 | Arrays | lesson_06_arrays.m |
Scalars, row/column vectors, matrices |
| 07 | Vectors | lesson_07_vectors.m |
Colon operator, linspace, transpose |
| 08 | Array Functions | lesson_08_array_functions.m |
rand, zeros, ones, eye, diag |
| 09 | Indexing | lesson_09_indexing.m |
Accessing elements with row,column indices |
| 10 | Extracting Elements | lesson_10_extracting.m |
Ranges, multiple elements, end keyword |
| 11 | Modifying Arrays | lesson_11_modifying_arrays.m |
Changing values, rows, columns, extending arrays |
-
Clone the repository:
git clone https://github.com/sametyilmaztemel/matlab-fundamentals.git cd matlab-fundamentals -
Open a lesson in MATLAB:
open lesson_01_commands.m
-
Run a script:
- Press F5 in the MATLAB Editor, or
- Type the script name in the Command Window:
>> lesson_01_commands -
Follow along lesson by lesson ā read the comments, run the code, and experiment!
- Command Window arithmetic
- Variable assignment and workspace management
- Output suppression with semicolons
- Saving and loading
.matfiles - The
clearcommand - File formats (binary
.matvs ASCII text)
- Built-in mathematical functions (
sin,cos,sqrt,exp,log) - Complex number support
- MATLAB constants (
pi,inf,NaN) - Creating and running script files
- Manual array creation with square brackets
[] - Scalars, row vectors, column vectors, matrices
- The colon operator
start:step:end linspacefor evenly spaced vectors- Transpose operator
'
rand(n),rand(r,c)ā random matriceszeros(r,c)ā zero-filled matricesones(r,c)ā ones-filled matriceseye(n)ā identity matricesdiag(v)ā diagonal matricesrandi(max,r,c)ā random integers
- 1-based indexing:
array(row, column) - The
endkeyword for last-index access - Extracting rows, columns, and sub-ranges
- Modifying individual elements, rows, and columns
- Extending arrays dynamically
matlab-fundamentals/
āāā README.md
āāā lesson_01_commands.m
āāā lesson_02_variables.m
āāā lesson_03_save_load.m
āāā lesson_04_builtin_functions.m
āāā lesson_05_scripts.m
āāā lesson_06_arrays.m
āāā lesson_07_vectors.m
āāā lesson_08_array_functions.m
āāā lesson_09_indexing.m
āāā lesson_10_extracting.m
āāā lesson_11_modifying_arrays.m
% Variables & Arithmetic result = 3 * 5; % Assign to variable result = result + 1; % Update variable % Built-in Functions y = sin(pi/2); % y = 1 z = sqrt(-9); % z = 3i (complex!) % Arrays row = [1 2 3]; % Row vector col = [1; 2; 3]; % Column vector mat = [1 2; 3 4]; % 2x2 matrix % Vector Creation v1 = 1:5; % [1 2 3 4 5] v2 = 0:0.5:2; % [0 0.5 1 1.5 2] v3 = linspace(0,1,5); % [0 0.25 0.5 0.75 1] % Array Functions R = rand(3,4); % 3x4 random matrix Z = zeros(2,3); % 2x3 zero matrix I = eye(4); % 4x4 identity matrix % Indexing val = R(2,3); % Element at row 2, col 3 row = R(1,:); % Entire first row col = R(:,end); % Last column % Modifying R(1,1) = 99; % Change single element R(:,2) = [0;0;0]; % Replace entire column
Contributions are welcome! Feel free to:
- Open an issue for suggestions or corrections
- Submit a pull request with improvements
- Share this repository with fellow learners
This project is licensed under the MIT License ā see the repository for details.
Author: Samet Yilmaz Temel
If you found this helpful, please consider giving it a ā star!