Introduccion a matlab

Páginas: 5 (1050 palabras) Publicado: 1 de noviembre de 2010
Introduction to MATLAB (Basics)

Reference from: Azernikov Sergei mesergei@tx.technion.ac.il

MATLAB Basics
• Where to get help? 1) In MATLAB’s prompt type: help, lookfor,helpwin, helpdesk, demos. 2) On the Web: http://www.mathworks.com/support
2

MATLAB’s Workspace
• • • • who,whos - current variables in workspace save - save workspace variables to *.mat file load - load variablesfrom *.mat file clear all - clear workspace variables

3

Matrices in MATLAB
• Matrix is a main MATLAB’s data type • How to build a matrix? A = [ 1 2 3; 4 5 6; 7 8 9 ]; Creates matrix A with size 3x3. • Special matrices : zeros(n,m), ones(n,m),eye (n,m)
4

Basic Operations on Matrices
• All the operators in MATLAB defined on matrices : +, -, *, /, ^, sqrt, sin, cos etc. • Element wiseoperators defined with preceding dot : .*, ./, .^ . • size(A) - size vector • sum(A) - columns sums vector • sum(sum(A)) - all the elements sum
5

Logical Conditions
• == , < , > , (not equal)~= ,(not)~ • find(‘condition’) - Returns indexes of A’s
elements that satisfies the condition.

6

Logical Conditions(cont.)
• Example:
>> A = [1 2; 3 4], I = find(A 0, E = E + F; F = A*F/N; N = N +1; end
16

Scripts and Functions
• There are two kinds of M-files:
– Scripts, which do not accept input arguments or return output arguments. They operate on data in the workspace. – Functions, which can accept input arguments and return output arguments. Internal variables are local to the function.
17

Functions in MATLAB

• FUNCTION Add new function. • New functions may be added toMATLAB' s vocabulary if they are expressed in terms of other existing functions.
18

Functions in MATLAB (cont.)
• Example :
The existence of a file on disk called STAT.M with: function [mean,stdev] = stat(x) %STAT Interesting statistics. n = length(x); mean = sum(x) / n; stdev = sqrt(sum((x - mean).^2)/n); defines a new function called STAT that calculates the mean and standard deviation ofa vector.
19

Visualization and Graphics
• • • • • • • • plot(x,y), plot(x,sin(x)) - plot 1-D function figure , figure(k) - open a new figure hold on, hold off - refreshing mesh(x_ax,y_ax,z_mat) - view surface contour(z_mat) - view z as top. map subplot(3,1,2) - locate several plots in figure axis([xmin xmax ymin ymax]) - change axes title(‘figure title’) - add title to figure
20

ImageProc. with MATLAB
(Please refer to Matlab Demo for more details of Image Processing Tool Box)

What Is the Image Processing Toolbox?
• The Image Processing Toolbox is a collection of functions that extend the capability of the MATLAB ® numeric computing environment. The toolbox supports a wide range of image processing operations, including:
– – – – – – – Geometric operations Neighborhoodand block operations Linear filtering and filter design Transforms Image analysis and enhancement Binary image operations Region of interest operations
22

MATLAB Image Types
• • • • Indexed images Intensity images Binary images RGB images : m-by-3 color map : [0,1] or uint8 : {0,1} : m-by-n-by-3

23

Indexed Images
» [x,map] = imread(' trees.tif' ); » imshow(x,map);

24

IntensityImages
» image = ind2gray(x,map); » imshow(image);

25

Binary Images
» imshow(edge(image));

26

RGB Images

27

Image Display
• • • • • • • image - create and display image object imagesc - scale and display as image imshow - display image colorbar - display colorbar getimage- get image data from axes truesize - adjust display size of image zoom - zoom in and zoom out of 2D plot28

Some Points to Note
Pixel values are accessed as matrix elements.
2D Image with intensity values: I(row,col) 2D RGB images I(row,col,color) - Color : Red = 1; Green = 2 ; Blue = 3

Displaying images
figure, imshow(I)

Displaying pixel position and intensity information
pixval on
29

Points to Note
All arithmetic operations performed on matrices may be performed on images...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Introduccion a matlab
  • Introduccion Al Matlab
  • Introduccion a Matlab
  • Introducción al matlab
  • Introduccion A Matlab
  • Introduccion a matlab
  • Introducción Al Matlab
  • introduccion a matlab

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS