0% found this document useful (0 votes)
29 views

Cours w1 Command Window Arrays

The document discusses learning computer science using Matlab. It covers Matlab basics like working modes, variables, arrays, and basic instructions. It provides links to online resources for a Matlab course on scientific computing including a Facebook group and YouTube channel.

Uploaded by

ahmedtoutou2003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Cours w1 Command Window Arrays

The document discusses learning computer science using Matlab. It covers Matlab basics like working modes, variables, arrays, and basic instructions. It provides links to online resources for a Matlab course on scientific computing including a Facebook group and YouTube channel.

Uploaded by

ahmedtoutou2003
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Computer science 3

Eng 2-EBT : 2023-2024


E learning
• Facebook Groupe :
www.facebook.com/groups/cs3eng2

• 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 Processing Output (Results)


How to write a program

- 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

1- Menu and tools bar.


2- Current folder.
3- command window
4- Workspace
5- Command history
Matlab : working modes

Matlab
working mode

Interactive Programming
Mode mode
Matlab – Interactive mode

command window :
Matlab – Interactive mode

Some useful commands:


clc : clear console
who : Displays variables list
whos : Displays detailed variables list (size, type).
clear x : delete variable x.
clear all : Delete all variables.
Matlab : VARIABLES

Variable definition:

x = 1 ( x receive 1)
Identifier value

Type ?
x 1
RAM
Matlab : Variables– (naming rules)

XXXX….X

Alphabet letter Special Characters Key word


A..Z ou a..z ./§~#{[|`\^ disp, input;
_ (underscore) @]}=+° function, if,
except : _ (underscoe) for
Matlab: Variables naming

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

1D array 2D array … ND array

Vector Matrix
Matlab : Arrays
Matlab : Arrays

Number Number of Total number


of rows columns of bytes
Matlab : Equidistant Arrays

The elements of the equidistant array are


equally spaced between a starting point and
an ending point.
Matlab : Equidistant Arrays

Equidistant array

Colon ':‘ linspace(…)


operator function
Matlab : Equidistant Arrays

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'.

• linspace(a, b, N) generates N points between 'a' and 'b'. (Equivalent


𝒃−𝒂
to 𝒂: :𝒃 )
𝑵−𝟏

𝟐−𝟏
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

You might also like