matlab - koyapetekoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 ·...

26
MATLAB Miran H. S. Mohammed Lecture 1 1

Upload: others

Post on 24-Jul-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

MATLAB

Miran H. S. Mohammed

Lecture 1 1

Page 2: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

OUTLINES

Introduction

Why using MATLAB

Installing MATLAB

Activate your installation

Getting started

Some useful command

Using MATLAB as a calculator

2

Page 3: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

INTRODUCTION

MATLAB is an extremely powerful software application and development tool that is widely used in most universities in technical fields.

MATLAB is an interactive system whose basic data element is an array that does not require dimensioning

MATLAB is available for Windows, Macintosh and UNIX systems. It is used by more than one million people in industry and academia.

MATLAB features a family of add-on application-specific solutions called toolboxes. Very important to most users of MATLAB, toolboxes allow you to learn and apply specialized technology. Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the MATLAB environment to solve particular classes of problems. You can add on toolboxes for signal processing, control systems, neural networks, fuzzy logic, wavelets, simulation, and many other areas.

3

Page 4: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Desktop Tools and Development Environment: This

is the set of tools and facilities that help you use

and become more productive with MATLAB

functions and files. Many of these tools are

graphical user interfaces. It includes the MATLAB

desktop and Command Window, a command

history, an editor and debugger, a code analyzer

and other reports, and browsers for viewing help,

the workspace, files, and the search path.

Mathematical Function Library: This is a vast

collection of computational algorithms ranging from

elementary functions, like sum, sine, cosine, and

complex arithmetic, to more sophisticated functions

like matrix inverse, matrix Eigen values, Bessel

functions, and fast Fourier transforms. 4

Page 5: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

The Language: This is a high-level matrix/array

language with control flow statements, functions, data

structures, input/output, and object-oriented

programming features. It allows both "programming in

the small" to rapidly create quick and dirty throw-away

programs, and "programming in the large" to create

large and complex application programs.

Graphics : MATLAB has extensive facilities for

displaying vectors and matrices as graphs, as well as

annotating and printing these graphs. It includes high-

level functions for two-dimensional and three-

dimensional data visualization, image processing,

animation, and presentation graphics. It also includes

low-level functions that allow you to fully customize the

appearance of graphics as well as to build complete

graphical user interfaces on your MATLAB applications.

5

Page 6: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

WHY USING MATLAB?

• Advantages:

• It allows quick and easy coding in a very high-level language.

• Rich data types: Complex number, Three dimensional matrix, structure, cell array, etc

• Lots of nice functions and toolboxes: fminsearch, fsolve, normcdf, norminv, etc; garch, optimization, symbolic, …

• Lots of users: economists, mathematicians, engineers, …

• High-quality graphics and visualization facilities are available.

• MATLAB M-files are completely portable across a wide range of platforms.

6

Page 7: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

So why is it called MATLAB? MATLAB is short

for MATrix LABoratory.

MATLAB was originally designed for

manipulating matrices. In fact, when you use a

simple variable such as x in MATLAB, it is

actually stored as a (|x|) matrix. In order to

understand how MATLAB works, we will need to

be familiar with matrix calculations. We will

cover more on this topic later.

7

Page 8: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

INSTALLING MATLAB

Before you install make sure!

Have your File Installation Key and License File

handy. You need both these items to perform an off-

network installation and activation.

Then, click on the installer icon from the drive(CD,

DVD, …)

8

Page 9: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Choose to Install Without Using the Internet

9

Page 10: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Review the License Agreement

10

Page 11: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Specify the File Installation Key

11

Page 12: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Choose the Installation Type

12

Page 13: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Specify the Installation Folder

13

Page 14: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Wait for finishing the installation

14

Page 15: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Program configuration note

15

Page 16: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Complete the Installation

16

Page 17: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

ACTIVATE YOUR INSTALLATION

Choose Activate manually without the Internet

17

Page 18: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Specify the Path to the License File

18

Page 19: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Complete the Activation

19

Page 20: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

GETTING STARTED

you can enter MATLAB by double-clicking on the

MATLAB shortcut icon on your Windows desktop.

When you start MATLAB, a special window called the

MATLAB desktop appears.

The desktop is a window that contains other windows.

The major tools within or accessible from the desktop

are:

The Command Window

The Command History

The Workspace

The Current Directory

The Help Browser 20

Page 21: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

Tool bar Menu bar

Current directory

Command window

Current folder

History command

Work space

21

Page 22: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

MATLAB Desktop:

Launch Pad: displays all the tools and

applications associated with MATLAB;

Command window: the space for writing your

codes.

Workspace: consists of the variables you create

during a MATLAB session;

Command History: double click them to

evaluate them;

Current Directory browser: shows you where

you are.

22

Page 23: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

SOME USEFUL COMMAND

Version: to show the version of MATLAB

cd : change directory to the root

cd .. : change directory one level

cd D:\ : change directory to drive D:

mkdir D:\name : make directory in D:

clc : clear screen

Clear: clear all

exit or quit: exit from the program

help about : getting help

Many other…

23

Page 24: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

USING MATLAB AS A CALCULATOR

You are now faced with the MATLAB desktop on

your computer, which contains the prompt (>>) in

the Command Window.

As an example of a simple interactive calculation,

just type the expression you want to evaluate.

For example, let's suppose you want to calculate

the expression, 1 + 2 * 3. You type it at the

prompt command (>>) as follows,

>> 1+2*3

ans = 7

24

Page 25: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

You will have noticed that if you do not specify an

output variable, MATLAB uses a default variable

ans, short for answer, to store the results of the

current calculation.

Note that the variable ans is created (or overwritten,

if it is already existed). To avoid this, you may assign

a value to a variable or output argument name. For

example,

>> x = 1+2*3

x = 7

will result in x being given the value 1 + 2 * 3 = 7.

This variable name can always be used to refer to the

results of the previous computations. Therefore,

computing 4x will result in

>> 4*x

ans = 28.0000 25

Page 26: MATLAB - KOYAPETEkoyapete.weebly.com/uploads/1/3/6/4/13645543/matlab_lec... · 2018-09-03 · Desktop Tools and Development Environment: This is the set of tools and facilities that

26