matlab ………………. matrix laboratory

of 19 /19
MATLAB ……………….matrix laboratory. Bhushan D Patil PhD Research Scholar Department of Electrical Engineering Indian Institute of Technology, Bombay Powai, Mumbai

Post on 15-Jan-2016

55 views

Category:

Documents

Embed Size (px)

DESCRIPTION

MATLAB ………………. matrix laboratory. Bhushan D Patil PhD Research Scholar Department of Electrical Engineering Indian Institute of Technology, Bombay Powai, Mumbai. What is MATLAB?. MATLAB is a high-performance language for technical computing. It - PowerPoint PPT Presentation

TRANSCRIPT

MATLAB……………….matrix laboratory.

Bhushan D PatilPhD Research Scholar Department of Electrical EngineeringIndian Institute of Technology, BombayPowai, Mumbai

What is MATLAB?

MATLAB is a high-performance language for technical computing. Itintegrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in familiarmathematical notation.

Typical uses include

•Math and computation•Algorithm development•Data acquisition•Modeling, simulation, and prototyping•Data analysis, exploration, and visualization•Scientific and engineering graphics•Application development, including graphical user interface building

Starting and Quitting MATLAB

Starting MATLAB Quitting MATLAB MATLAB Desktop

Editor/Debugger

Array Editor

Matrices and Arrays

A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1]A =16 3 2 135 10 11 89 6 7 124 15 14 1

sum, transpose, and diagsum(A)ans = 34 34 34 34A‘ans = 16 5 9 4

3 10 6 15 2 11 7 14

13 8 12 1

diag(A)ans =

161071

Generating Basic Matrices

zeros All zerosZ = zeros(2,4)Z =

0 0 0 00 0 0 0

ones All onesF = 5*ones(3,3)F =

5 5 55 5 55 5 5

rand Uniformly distributed random elementsN = fix(10*rand(1,10))N =

9 2 6 4 8 7 4 0 8 4

randn Normally distributed random elementsR = randn(4,4)R =

0.6353 0.0860 -0.3210 -1.2316-0.6014 -2.0046 1.2366 1.05560.5512 -0.4931 -0.6313 -0.1132-1.0998 0.4620 -2.3252 0.3792

ConcatenationB = [A A+32; A+48 A+16]B =

16 3 2 13 48 35 34 455 10 11 8 37 42 43 409 6 7 12 41 38 39 444 15 14 1 36 47 46 3364 51 50 61 32 19 18 2953 58 59 56 21 26 27 2457 54 55 60 25 22 23 2852 63 62 49 20 31 30 17

Deleting Rows and ColumnsX = A;X(:,2) = []X =

16 2 135 11 89 7 124 14 1

inv(A) eig(A)

SubscriptsA(1,4) + A(2,4) + A(3,4) + A(4,4)The Colon Operator1:10ans1 2 3 4 5 6 7 8 9 10

100:-7:50ans100 93 86 79 72 65 58 51

0:pi/4:pians0 0.7854 1.5708 2.3562 3.1416

The list of operators includes

+ Addition- Subtraction.* Element-by-element multiplication./ Element-by-element division.\ Element-by-element left division.^ Element-by-element power

Graphics

Figure Tools

Preparing Graphs

x = -10:.005:40;y = [1.5*cos(x)+4*exp(-.01*x).*cos(x)+exp(.07*x).*sin(3*x)];plot(x,y)

Multiple Data Sets in One Graph

x = 0:pi/100:2*pi;y = sin(x);y2 = sin(x-.25);y3 = sin(x-.5);plot(x,y,x,y2,x,y3)legend('sin(x)','sin(x-.25)','sin(x-.5)')

Mesh and Surface Plots

[X,Y] = meshgrid(-8:.5:8);R = sqrt(X.^2 + Y.^2) + eps;Z = sin(R)./R;mesh(X,Y,Z,'EdgeColor','black')

Programming

if, else, and elseifif A > B'greater'elseif A < B'less'elseif A == B'equal'elseerror('Unexpected situation')end switch and caseswitch (rem(n,4)==0) + (rem(n,2)==0)case 0M = odd_magic(n)case 1M = single_even_magic(n)case 2M = double_even_magic(n)otherwiseerror('This is impossible')end

Forfor n = 3:32r(n) = rank(magic(n));end Nested forfor i = 1:mfor j = 1:n

H(i,j) = 1/(i+j);endend whileWhile(i<25) a=a+2;end break

Toolbox available Communications Control System Curve Fitting Fuzzy Logic Image Processing Instrument Control Robust Control Signal Processing System Identification Virtual Reality Wavelet