SE207 Lab 2 - PowerPoint PPT Presentation

About This Presentation
Title:

SE207 Lab 2

Description:

saved on a file for convenience. no input argument. The variables are global. FUNCTION files ... New. M-file. Open. M-file. MATRIX OPERATIONS. Transpose A' ... – PowerPoint PPT presentation

Number of Views:14
Avg rating:3.0/5.0
Slides: 9
Provided by: Fade7
Category:
Tags: convenience | lab | se207

less

Transcript and Presenter's Notes

Title: SE207 Lab 2


1
SE207 Lab 2
  • Objective
  • To be able to create script and function files

2
MATLAB Files
  • Two types of files
  • SCRIPT files
  • FUNCTION files
  • Both have the extension .m M-files
  • (file1.m, f2.m)

3
M-files
  • SCRPT Files
  • a list of MATLAB instructions
  • saved on a file for convenience
  • no input argument
  • The variables are global
  • FUNCTION files
  • Starts with FUNCTION statement that specifies
    the input and output arguments
  • Local variables
  • Treated as the built-in functions

t00.110 ysin(t) plot(t,y)
function yfplot2(t) ysin(t) plot(t,y)
4
Function M-files
  • create an m-file and save it as fplot.m

FILE
New
M-file
function yfplot(t) ysin(t)
Open
M-file
  • MATLAB Command Window

gtgt t00.110 gtgt zfplot(t) gtgt plot(t,z)
5
MATRIX OPERATIONS
  • Transpose A
  • inverse inv(A)
  • determinant det(A)
  • rank rank(A)

6
Special functions
  • Exponential exp(x)
  • square root sqrt(x)
  • natural logarithm log(x)
  • common logarithm log10(x)
  • absolute value abs(x)

more
details Use help to know
related functions
7
If structures
  • General form
  • If condition
  • statements
  • else
  • statements
  • end

If (xgt0) fx2 else f0 end
8
for loops
  • General form
  • for indexinitial increment limit
  • statements
  • end
  • special case
  • if increment is 1
  • for indexinitial limit

for i1100 x(i)sin(i.2) end
Write a Comment
User Comments (0)
About PowerShow.com