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

Lect 1

This document provides an introduction to basic Matlab instructions for loading and visualizing signals and images. It discusses how to create and modify variables and matrices, use basic mathematical functions, display plots and text, and load/plot sample signal and image data using provided load functions. Functions covered include ones to create vectors and matrices, access entries, sort values, threshold data, plot 1D and 2D graphs, divide the screen into subplots, use loops and conditional statements, and load/display example signal and image files.

Uploaded by

jains.boy
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lect 1

This document provides an introduction to basic Matlab instructions for loading and visualizing signals and images. It discusses how to create and modify variables and matrices, use basic mathematical functions, display plots and text, and load/plot sample signal and image data using provided load functions. Functions covered include ones to create vectors and matrices, access entries, sort values, threshold data, plot 1D and 2D graphs, divide the screen into subplots, use loops and conditional statements, and load/display example signal and image files.

Uploaded by

jains.boy
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lecture 0 - Basic Matlab Instructions

Abstract : Learn the basic features of Matlab, and learn how to load and visualize signals and images.

Basic Matlab commands.

Create a variable and an array % this is a comment a = 1; a = 2+1i; % real and complex numbers b = [1 2 3 4]; % row vector c = [1; 2; 3; 4]; % column vector d = 1:2:7; % here one has d=[1 3 5 7] A = eye(4); B = ones(4); C = rand(4); % identity, 1 and random matrices c = b'; % transpose

Modification of vectors and matrices A(2,2) = B(1,1) + b(1); % to access an entry in a vector or matrix b(1:3) = 0; % to access a set of indices in a matrix b(end-2:end) = 1: % to access the last entries b = b(end:-1:1); % reverse a vector b = sort(b); % sort values b = b .* (b>2); % set to zeros (threshold) the values below 2 b(3) = []; % supress the 3rd entry of a vector B = [b; b]; % create a matrix of size 2x4 c = B(:,2); % to access 2nd column

Advanced instructions a = cos(b); a = sqrt(b); % usual function help perform_wavelet_transform; % print the help a = abs(b); a = real(b); a = imag(b); a = angle(b); % norm, real part and imaginary part of a complex disp('Hello'); % display a text disp( sprintf('Valeur de x=%.2f', x) ); % print a values with 2 digits A(A==Inf) = 3; % replace Inf values by 3 A(:); % flatten a matrix into a column vector max(A(:)); % max of a matrix M = M .* (abs(M)>T); % threshold to 0 values below T.

Display

plot( 1:10, (1:10).^2 ); % display a 1D function title('Mon titre'); % title xlabel('variable x'); ylabel('variable y'); % axis subplot(2, 2, 1); % divide the screen in 2x2 and select 1st quadrant

Programmation for i=1:4 % disp(i); end i = 4; while i>0 % disp(i); i = i-1; end repeat the loop for i=1, i=2, i=3 et i=4 % make here something while syntax % do smth

Load and visualize signals and images

Load and plot a signal : (function load_signal.m should be in the toolbox of each course) f = load_signal('Piece-Regular', n); % signal of size n plot(f);

Load and display an image (download function load_image.m should be in the toolboxes) I = load_image('lena'); imagesc(I); axis image; colormap gray(256);

You might also like