Presentation is loading. Please wait.

Presentation is loading. Please wait.

Signals in Matlab Matlab as a name stands for Matrix Laboratory.

Similar presentations


Presentation on theme: "Signals in Matlab Matlab as a name stands for Matrix Laboratory."— Presentation transcript:

1 Signals in Matlab Matlab as a name stands for Matrix Laboratory.
As the name implies it uses Matrices to manipulate differential equations, Signals, … etc Any complex problem can be subdivided to simple matrix operations and simulated using Matlab. © Ashraf Ali

2 Introduction to Matlab
Matlab has a user friendly GUI. We can use either the command prompt or Simulink (drag drop tool in Matlab) to simulate problems. Command prompt in Matlab is used to define variables, enter commands and implement the needed variable operations. Simulink has a set of toolboxes with built in defined functions that saves the time of defining functions. © Ashraf Ali

3 © Ashraf Ali

4 Matrices in Matlab To enter a matrix >> A = [3 1 ; 6 4]
3 1 6 4 >> A = [3 1 ; 6 4] >> A = [3, 1 ; 6, 4] >> B = [3, 5 ; 0, 2] © Ashraf Ali

5 Basic Mathematical Operations
Addition: >> C = A + B Subtraction: >> D = A – B Multiplication: >> E = A * B (Matrix multiplication) >> E = A .* B (Element wise multiplication) Division: Left Division and Right Division >> F = A . / B (Element wise division) >> F = A / B (A * inverse of B) >> F = A . \ B (Element wise division) >> F = A \ B (inverse of A * B) © Ashraf Ali

6 Generating basic matrices
Matrix with ZEROS: >> Z = ZEROS (r, c) Matrix with ONES: >> O = ONES (r, c) IDENTITY Matrix: >> I = EYE (r, c) r  Rows c  Columns zeros, ones, eye  Matlab functions © Ashraf Ali

7 Plot function Ex X=-pi:0.1:pi ; % define vector x begins from – π to π with a step of 0.1, the semi colon at the end prevent displaying all the values on the screen. Y= sin(x); % define another vector y that has the same number of entries of x. Plot (x,y); % plot the relation between x and y. © Ashraf Ali

8 Plot example © Ashraf Ali

9 Subplot command subplot(m,n,P) % this command plots multiple plots in the same figure window, m is the number of rows, n is the number of columns and p is the position of the plot. Ex: fs=100;  % sampling frequency t=0:1/fs:1; % setup time from 0 to 1 second f=5;       % input frequency x=sin(2*pi*f*t);            % input signal subplot(211); % define two rows one column of plots (two plots), the next plot command will take position 1. plot(t,x); %This plot will take position 1 (the upper plot) title('Continuous-time'); % put a title above the plot. subplot(212); % next plot command will take position 2 (the lower plot) stem(t,x); % stem is similar to plot but it shows stems at discrete time. © Ashraf Ali

10 © Ashraf Ali


Download ppt "Signals in Matlab Matlab as a name stands for Matrix Laboratory."

Similar presentations


Ads by Google