Top Banner
PRESENTATION ON MATLAB
29

Matlab

Aug 18, 2015

Download

Engineering

sandhya jois
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Matlab

PRESENTATION ON MATLAB

Page 2: Matlab

contents•Introduction to matlab• Availability of matlab•Difference between c and matlab•Introduction to simulink•Desktop Tools•Variables•3 Dimensional Plot•Simple operations on vector and matrices•Usage of if,for and while loops in matlab•Functions and generating vectors from function• Simulating a source•Simple program to plot a sine wave•Matlab application in commercially available nao robots.•List of companies working on matlab•Applications of matlab

Page 3: Matlab

Introduction

Cleve molar in 1984, Mathworks inc

Introduced as a simulation toolSupports Graphical

ProgrammingCan be interfaced with other

High Level languages

Page 4: Matlab

MATLAB INTRODUCTION

• Matlab is both computer programming language and software environment for using that language effectively.

• Matlab is matrix-oriented, so what would take several statements in c or fortran can usually be accomplished in just a few lines using matlab's built-in matrix and vector operations

Page 5: Matlab

What is Matlab?• Matlab is basically a high level language which

has many specialized toolboxes for making things easier for us

• How high?

Assembly

High Level Languages such as

C, Pascal etc.

Matlab

Page 6: Matlab

AVAILABILITY OF MATLAB

• Matlab is available for ms windows, Macintosh personal computer, Unix and other operating systems. • MATLAB,which stands for MATRIX LABORATPORY, is a powerful, general-purpose system or environment for doing mathematics, scientific and engireeng calculations.

Page 7: Matlab

Introduction to simulink

– Used to model, analyze and simulate dynamic systems using block diagrams.

– Fully integrated with MATLAB , easy and fast to learn and flexible.

– It has comprehensive block library which can be used to simulate linear, non–linear or discrete systems – excellent research tools.

– C codes can be generated from Simulink models for embedded applications and rapid prototyping of control systems.

Page 8: Matlab

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

Page 9: Matlab

Change the current working directory

Page 10: Matlab

Variables• No need for types. i.e.,

• All variables are created with double precision unless specified and they are matrices.

• After these statements, the variables are 1x1 matrices with double precision

int a;double b;float c;

Example:>>x=5;>>x1=2;

Page 11: Matlab

Data visualisation – plotting graphsExample on mesh and surf – 3 dimensional plot

Page 12: Matlab

Vectors

a = [1 2 3 4 5 6 9 8 7] ;

t = 0:2:20t = 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

Page 13: Matlab

Matrices

B = [1 2 3 4;5 6 7 8;9 10 11 12] ;

B = 1 2 3 4 5 6 7 8

9 10 11 12

C = B'

C = 1 5 9 2 6 103 7 11

4 8 12

Page 14: Matlab

IF LOOP

a=6;

if a > 6 disp('a is greater'); elseif a==0 disp('a is zero'); else disp('a is smaller'); end

Page 15: Matlab

FOR LOOP

a=5;

for i=1:5 a=a+1 end

disp(a);

ANS a =10

Page 16: Matlab

While Loop

a=5;

while a < 10a=a+1; end

disp(a);

Ans a =10

Page 17: Matlab

Function

function c=add(a,b);c=a+b;return

Maina=5;b=6;c=add(a,b);disp(c);d=mul(a,b);disp(d);

function c=mul(a,b);c=a*b;return

Page 18: Matlab

Generating Vectors from functions• zeros(M,N) MxN matrix of zeros

• ones(M,N) MxN matrix of ones

• rand(M,N) MxN matrix of uniformly distributed

random numbers on (0,1)

x = zeros(1,3)x =

0 0 0

x = ones(1,3)x =

1 1 1

x = rand(1,3)x = 0.9501 0.2311 0.6068

Page 19: Matlab

Generate message signal (simple sine wave)

Define time instants (1000 sample points)tmin = 0; tmax = 10^(-3); step = (tmax-tmin)/1000;t = tmin:step:tmax;

Define amplitude and frequency (initial phase is zero)Vm = 1; % Amplitudefm = 2*10^3; % Frequency

Construct the Signalm = Vm*sin(2*pi*fm*t);

View the Signalplot(t,m,'r');

Simulate a Source

tfVtm mm 2sin

Page 20: Matlab

Complete MATLAB Script [Prog1.m]

tmin = 0; tmax = 10^(-3); step = (tmax-tmin)/1000;t = tmin:step:tmax; fm = 2*10^3; Vm = 1; m = Vm*sin(2*pi*fm*t); plot(t,m,'r');

Simulate a Source

Page 21: Matlab

Simulate a Source

Page 22: Matlab

PLOT

t=0:0.25:7; y = sin(t); plot(t,y) ; xlabel('x axis'); ylabel('y axis'); title('Heading'); grid on; gtext('text');

Page 23: Matlab
Page 24: Matlab

APPLICATION OF MATLAB IN ROBOTS

• The MATLAB NAO API enables you to control the NAO robot via MATLAB and related toolboxes.

• The API enables MATLAB to send and receive data asynchronously to the robot over a TCP/IP link (wireless or wired) between the host PC and the robot.

• For example, the API receives images taken by the mounted cameras on NAO. it can use face detection algorithms to identify faces in the images.

• The API can then send a voice phrase, such as the name of the person, to the speakers on NAO or have the robot walk toward or away from particular people.

Page 25: Matlab

• Programming NAO robot with just MATLAB• Expand capabilities at any time with additional

toolboxes• Work in the MATLAB environment for interactive

development and debugging• Develop programs using NAO’s sensors (inputs) and

actuators (outputs) such as microphone, camera, accelerometer, touch sensors, joint DC motors, LEDs, and speakers

• Introduce electronics, mathematics, mechanics, control, image processing, voice recognition, navigation and more using MATLAB

Page 26: Matlab
Page 27: Matlab

List of Companies

• ADOBE (Photoshop)• NASA• GE• L&T• ROBERT BOSCH

Page 28: Matlab

Applications

• Aerospace• Biometrics• Medical• Signal,Image,Audio and Video• Neural networks,Fuzzy logic• Animation

Page 29: Matlab

THANK YOU