Professional Documents
Culture Documents
Introduction
Cleve molar in 1984, Mathworks inc Introduced as a simulation tool Supports Graphical Programming Can be interfaced with other High Level languages
Applications
Aerospace Biometrics Medical Finance Control System Signal,Image,Audio and Video Neural networks,Fuzzy logic Animation
Copyright 2006 Pantech Solutions Pvt Ltd.
List of Companies
ADOBE (Photoshop) NASA GE L&T ROBERT BOSCH PEPSI , COCACOLA (Neuro Marketing)
File Extensions
.fig
MATLAB Figure
.m MATLAB function, script, or class .mat MATLAB binary file for storing variables .mex MATLAB executable (platform specific, e.g. ".mexmac" for the Mac, ".mexglx" for Linux, etc.) .p MATLAB content-obscured .m file (result of pcode() )
Technology beyond the Dreams
Copyright 2006 Pantech Solutions Pvt Ltd.
Desktop Tools
Command Window type commands Workspace view program variables clear to clear double click on a variable to see it in the Array Editor Command History view past commands save a whole session using diary Launch Pad access tools, demos and documentation
Command window
Arithmetic operators
1) 2) 3) 4) 5) 6) 7) 8) 9) 10) 11) 12)
plus - Plus + uplus - Unary plus + minus - Minus uminus - Unary minus mtimes - Matrix multiply * times - Array multiply .* mpower - Matrix power ^ power - Array power .^ mldivide - Backslash or left matrix divide \ mrdivide - Slash or right matrix divide / ldivide - Left array divide .\ rdivide - Right array divide ./
Relational operators
1) 2) 3) 4) 5) 6)
eq ne lt gt le ge - Equal - Not equal - Less than - Greater than - Less than or equal - Greater than or equal == ~= < > <= >=
Logical operators
1) Short-circuit logical AND && 2) Short-circuit logical OR || 3) and - Element-wise logical AND & 4) or - Element-wise logical OR | 5) not - Logical NOT ~ 6) xor - Logical EXCLUSIVE OR 7) any - True if any element of vector is nonzero 8) all - True if all elements of vector are nonzero
BITWISE OPERATORS
1) 2) 3) 4)
5) 6) 7) 8)
bitand bitcmp bitor bitmax - Bit-wise AND. - Complement bits. - Bit-wise OR. - Maximum floating point integer. bitxor - Bit-wise XOR. bitset - Set bit. bitget - Get bit. bitshift - Bit-wise shift.
Vectors
a = [1 2 3 4 5 6 9 8 7] ; t = 0:2:20 t = 0 2 4 6 8 10 12 14 16 18 20
b=a+2
b = 3 4 5 6 7 8 11 10 9
c=a+b c = 4 6 8 10 12 14 20 18 16
Matrices
B = [1 2 3 4;5 6 7 8;9 10 11 12] ;
B=1234 5678 9 10 11 12
C = B'
C=159 2 6 10 3 7 11 4 8 12
Convolution
x = [1 2]; y = [1 4 8]; z = conv(x,y) [xx, R] = deconv(z,y)
PLOT
t=0:0.25:7; y = sin(t); plot(t,y) ; xlabel('x axis'); ylabel('y axis'); title('Heading'); grid on; gtext('text');
IF LOOP
a=6; if a > 6 disp('a is greater'); elseif a==0 disp('a is zero');
else
disp('a is smaller'); end
Technology beyond the Dreams
Copyright 2006 Pantech Solutions Pvt Ltd.
FOR LOOP
a=5; for i=1:5 a=a+1 end disp(a); ANS a =10
While Loop
a=5; while a < 10 a=a+1; end disp(a);
Ans a =10
Function
function c=add(a,b); c=a+b; return Main a=5; b=6; c=add(a,b); disp(c); d=mul(a,b); disp(d);
SWITCH CASE
method = 'Bilinear'; switch lower(METHOD) case {'linear','bilinear'} disp('Method is linear') case 'cubic' disp('Method is cubic') case 'nearest' disp('Method is nearest') otherwise disp('Unknown method.') end Ans Method is linear
Technology beyond the Dreams
Copyright 2006 Pantech Solutions Pvt Ltd.
SWITCH (NUMERICAL)
a=input('enter---->'); switch a case 1 fprintf('one'); case 2 fprintf('two'); case 3 fprintf('three'); case 4 fprintf('four'); otherwise fprintf('otherwise'); end
RGB component
a=imread('flowers.tif'); subplot(2,2,1); imshow(a); R=a; G=a; B=a; R(:,:,2:3)=0; subplot(2,2,2); imshow(R); G(:,:,1)=0; G(:,:,3)=0; subplot(2,2,3); imshow(G); B(:,:,1)=0; B(:,:,2)=0; subplot(2,2,4); imshow(B);
hello
Store an Image,Audio
a =imread('cameraman.tif'); imwrite(a,'new.bmp'); a=wavread('test.wav'); wavwrite(d,44100,16,'nTEST.WAV');
Wavelet transform
a =imread('cameraman.tif'); [LL LH HL HH]=dwt2(a,'haar'); Dec=[... LL,LH HL,HH ... ]; imshow(Dec,[]);
Technology beyond the Dreams
Copyright 2006 Pantech Solutions Pvt Ltd.
DCT transform
a=imread('cameraman.tif'); subplot(1,3,1);imshow(a,[]); b=dct2(a); subplot(1,3,2);imshow(b,[]);title('DCT'); c=idct2(b); subplot(1,3,3);imshow(c,[]);title('IDCT');
GUI
DIALOG BOX
warndlg('hello'); helpdlg('hello'); errordlg('hello');
msgbox('hello');
ButtonName=questdlg('What is your wish?', ... 'Genie Question', ... 'Food','Clothing','Money','Money'); switch ButtonName, case 'Food', disp('Food is delivered'); case 'Clothing', disp('The Emperor''s new clothes have arrived.') case 'Money', disp('A ton of money falls out the sky.'); end % switch
GUI
GUI
MENU BAR
PUSH BUTTON
TOGGLE BUTTON
RADIO BUTTON
CHECKBOX
EDIT TEXT
STATIC TEXT
SLIDER
FRAME
LISTBOX
POPUP MENU
AXES
ALIGN OBJECTS
MENU EDITOR
M FILE EDITOR
PROPERTY INSPECTOR
RUN
EMPTY GUI
GENERATED M FILE
PUSH BUTTON
GO FOR CALLBACK
CHOOSE AXES
CHOOSE AXES
CODE
a =imread('cameraman.tif'); axes(handles.one); imshow(a);
TOGGLE BUTTON
contents = get(hObject,'Value')
switch contents
case 1 a =imread('cameraman.tif'); axes(handles.one); imshow(a); case 2 a =imread('flowers.tif'); axes(handles.one); imshow(a); case 3 a =imread('rice.tif'); axes(handles.one); imshow(a); otherwise a =imread('mri.tif'); axes(handles.one); imshow(a); end
CHOOSE POPUPMENU
switch contents
case 1 a =imread('cameraman.tif'); axes(handles.one); imshow(a); case 2 a =imread('flowers.tif'); axes(handles.one); imshow(a); case 3 a =imread('rice.tif'); axes(handles.one); imshow(a); otherwise a =imread('mri.tif'); axes(handles.one); imshow(a); end
SLIDER
GO FOR CALLBACK
MENU EDITOR
RUN
Cont 2
for i=1:rows for j=1:columns if BinaryMask(i,j) == 1 SegmentedImage(i,j,1)=InputImage(i,j,1); SegmentedImage(i,j,2)=InputImage(i,j,2); SegmentedImage(i,j,3)=InputImage(i,j,3); else SegmentedImage(i,j,1)=0; SegmentedImage(i,j,2)=0; SegmentedImage(i,j,3)=0; end end waitbar(i/rows,h) end SegmentedImage=uint8(SegmentedImage); figure; imshow(SegmentedImage); impixelinfo;
Image Fusion
clc; clear; close all; M1=imread('mri.jpg'); M2=imread('ct.jpg'); subplot(2,2,1);imshow(M1);title('MRI'); subplot(2,2,2);imshow(M2);title('CT'); [R C P]=size(M1); for i=1:R for j=1:C if M1(i,j)>M2(i,j) FusedImage(i,j)=M1(i,j); else FusedImage(i,j)=M2(i,j); end end end
Image fusion-Cont 2
subplot(2,2,3);imshow(FusedImage);title('Max'); for i=1:R for j=1:C if M1(i,j)>M2(i,j) FusedImage(i,j)=M2(i,j); else FusedImage(i,j)=M1(i,j); end end end subplot(2,2,4);imshow(FusedImage);title('Min');