E7_discussion_2008_09_26_bw

E7_discussion_2008_09_26_bw - COMPUTER FUNCTION function...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
9/25/2008 1 COMPUTER FUNCTION function FILE y = F(x) data in data out Matlab BUILT-IN FUNCTIONS length, size, isempty, exist, what, which, … reshape, repmat, ones, zeros, eye, cell, … sin, cos, tan, . .., asin, acos, atan, . .. exp, log, log10, log2, . .. sqrt sqrt, . .. sign, round, fix, ceil, floor, . .. sum, prod, max, min, mean, … plot, loglog, semilogx, semilogy, plot3, … bar, hist, bar3, bar3h, … find, findmax, sort, sortrows, any, all, … command window workspace editor function script >> function space workspace Function Space command window workspace >> a = 5 >> b = fun(a) 7 function y = fun(x) y = x + 2; EXAMPLE: Rotation of Coordinate Axes x y x y ϕ cos sin sin cos xx y yx y φ =− =+ cos sin sin cos y y Matlab M-file: Script (rotation.m) % Example: rotating coordinate axes point = [1; 1] % column vector of initial coordinates phi = 60 * (pi/180) % angle in radians rotationMatrix = [ cos(phi) -sin(phi) sin(phi) cos(phi) ] newPoint = rotationMatrix * point plot(newPoint(1), newPoint(2),’or’) % plot the new point grid on, axis([-2 2 -2 2]), axis square title(['angle = ' num2str(phi*180/pi) ' degrees'])
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
9/25/2008 2 Matlab M-file: Function (rotation2.m) function rotation2 % Example: rotating coordinate axes point = [1; 1] % column vector of initial coordinates phi = 60 * (pi/180) % angle in radians rotationMatrix = [ cos(phi) -sin(phi) sin(phi) cos(phi) ] newPoint = rotationMatrix * point plot(newPoint(1), newPoint(2),’or’)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/01/2009 for the course ENGLISH 7 taught by Professor Sengupta during the Spring '09 term at Berkeley.

Page1 / 3

E7_discussion_2008_09_26_bw - COMPUTER FUNCTION function...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online