1. Trang chủ
  2. » Công Nghệ Thông Tin

matlab tutorial english ebook

36 200 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 36
Dung lượng 1,31 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

I don’t know how to make them.. Function name = filenameCan have additional hidden functions... Files: Scripts and... THE INTERFACECurrent Directory / Workspace Command Window Interactiv

Trang 1

Matlab Tutorial

Joseph E Gonzalez

Trang 3

Why we use it?

Trang 5

Matlab Language

Nap Time

Z

Trang 7

Logic and Assignment

% Assignment with equality

ans: 1 % 1 is true in Matlab

not( a == 6 ) also works

Trang 11

More Making Matrices

% Creating all ones, zeros, or identity matrices

>> zeros( rows, cols )

>> ones( rows, cols )

>> eye( rows )

% Creating Random matrices

>> rand( rows, cols ) % Unif[0,1]

>> randn( rows, cols) % N(0, 1)

% Make 3x5 with N(1, 4) entries

>> 1 + 2 * randn(3,5)

% Get the size

>> [rows, cols] = size( matrix );

Trang 12

Array and Matrix Indices

Start at 1 not 0.

(Fortran)

Trang 14

-1 5 -1

7 -1 9

Trang 15

>> A / A

ans: 1 1 1

1 1 1

1 1 1

Trang 16

Matrix Math 2

% Make a matrix

>> A = [1 2 3; 4 5 6; 7 8 9]ans: 1 2 3

Trang 17

16 25 36

49 64 81

Trang 18

% Solving Systems

>> (A + eye(3)) \ [1;2;3] % inv(A + eye(3)) * [1; 2; 3]ans: -1.0000

-0.0000 1.0000

Trang 21

% Provide a convenient tool to organize variables

% Create Structs on the fly

Trang 22

You can make objects but

you won’t need them.

I don’t know how to make them most people don’t use them

Trang 23

If statements

% If Statements

>> c = rand();

>> if (c > 5) %% conditional disp(‘Greater than’);

Trang 24

% Avoid using for loops

>> count = sum( data(:,1) == 4 & data(:,3) == 2 )

% How would you compute the outer product of a row vector?

>> repmat(x, length(x), 1) * repmat(x’, 1,length(x))

Outer Product of row vector x

Trang 25

Function name = filename

Can have additional (hidden) functions

Trang 26

Files: Scripts and

Trang 27

>> yans: 4

>> xpans: 5

Trang 29

THE INTERFACE

Current Directory

/ Workspace

Command Window Interactive Shell Recent

Commands

Trang 30

>> pwd ans = /Users/jegonzal/tutorial

>> cd

>> pwd ans = /Users/jegonzal

ls : List Directory Contents

pwd : View Current directory

cd : Change Directory

Trang 31

Other Commands

% Get help on a function

>> help <function name>

% List names of variables in the environment

Trang 32

Help organize your programs

Can only call functions and scripts in:

The present working directory (pwd)

The Matlab path (path)

Call functions and scripts by typing name

>> my_script

>> y = my_function(x)

Trang 33

GO PLAY WITH THE COMMAND WINDOW

Trang 34

EDITOR

Trang 35

Insert break points

Click to the left of the

line (Red Circle)

Use interactive shell

K>> K>> beta beta =

1 -5 6

Trang 36

Walk Through Interface

Ngày đăng: 24/10/2014, 23:20

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN