Cours w1 Command Window Arrays
Cours w1 Command Window Arrays
• online course
www.Moodle-ft.univ-setif.dz
E learning
•YouTube :
Fouad CHOUAG
•Faculty website
www.Ft.univ-setif.dz
Objectif
Mastering coding with
Matlab
for scientific computing
Program / Application
- Input ? - Variables
- Output ? - instrunctions
- Processing : How to find
ouput from input?
Matlab
MATrix LABoratory
high-performance modern
matrix-based language for
scientific computing
Matlab 2013a interface
Matlab
working mode
Interactive Programming
Mode mode
Matlab – Interactive mode
command window :
Matlab – Interactive mode
Variable definition:
x = 1 ( x receive 1)
Identifier value
Type ?
x 1
RAM
Matlab : Variables– (naming rules)
XXXX….X
tp ≠ Tp ≠ tP ≠ TP
(4 variables ---<Matlab is case sensitive)
Matlab : VARIABLES (Types)
Basic Types :
double : real number 2.4, 7.9….
Char : Character ('A', 'ecole'... )
logical : true / false
Matlab : VARIABLES (Types)
the value 2 is assigned as an integer to
the variable x, but MATLAB interprets it
as a double
Matlab : VARIABLES (Types)
Matlab : Arrays
Arrays
Vector Matrix
Matlab : Arrays
Matlab : Arrays
Equidistant array
Colon ':‘ :
• a:b generates a row vector [ a a+1 a+2 …… b ]
v1 = 1:7 v1 = 1 2 3 4 5 6 7
• a:p:b generates a row vector [ a a+p a+2p …… b ]
v2 = 1:2:7 v2 = 1 3 5 7
Matlab : Arrays
• linspace(a, b) generates a row vector of 100 linearly equally spaced
points between 'a' and 'b'.
𝟐−𝟏
ex : v3 = linspace(1, 2, 5) Equivalent to 𝟏: :𝟐 and this creates
𝟓−𝟏
v3 = 1 1.25 1.50 1.75 2
Basic Instructions
•Assignement(=)
Next session
•input(…)
ان شاء هللا
•disp(…) / fprintf (…)
Questions