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

Matlab - Variables

Uploaded by

mansour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Matlab - Variables

Uploaded by

mansour
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Session 1: Array Matrices

%% Lessen one y = sin(x);


plot(y)
% MatLab: Matrix Laboratory
% Every thing a matrix: Image, %% Matrix--------------
Video, Voice, ... clc
% The Key in MatLab: Matrix A = [8, 1, 6; 3,5,7; 4 9 2]
Manopulating B = [2 3 4
5 7 10
% Variable defintions: case 9 11 13];
sensitive, letter [s]+num _[c]
a = 2; Ad = diag(A)
b_ = 4, b4 = 5 Ad_s = sum(Ad)
% Predifined Variables Ad_s = sum(diag(A));
pi, beep,
% clc, clear, close Adi = diag(flipud(A))
Adi = diag(fliplr(A));
%% Array --------------------- Adi_s = sum(diag(flipud(A)));
a = [-1, 7, 3 4];
disp(a) % Sum of each column-----------
whos a sum(A)
size a
% Matrix Indexing----------
a1 = 1:5; C = magic(4)
b = 1:2:8; c1 = C(2,4)
b2 = 20: -1.5: 0; C(4,1) = 100;
% Matrix Concatination----------- C([1,2],2)
c = [a1, -b]; C(1:4, 2)
% Transpose---------------------- C(:, 2)
b' C(3, 2:end)
C(3, 2:end-1)
% Array Operations------------- J = sum(sum(C))
a + b m = C(1,:);
a - b mi = m(end:-1:1)
% a*b ?
a.*b P = pascal(4)
P([2 3],[2 4])
a + ones(1,4) P(5,1) = 9
a + 1
a*5 % ones, zeros, rand, randn--------

% Operators precedence----------
k = 5-2:-1:0

%
sin(30)
th = [30 45 90 120];
sin(th / 180 * pi)
%
x = linspace(0, 2*pi, 50);

MATLAB Course By: Mansour Torabi

You might also like