class_notes17

class_notes17 - Engineering 3 Class 17 Today: functions in...

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

View Full Document Right Arrow Icon
Engineering 3 – Class 17 Today: • functions in MATLAB Discussion section today (last one…)
Background image of page 1

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

View Full DocumentRight Arrow Icon
To obtain multiple outputs from a function, put variables in row-vector form: [val ind] = max(v) This returns the maximum value in val and it’s location (index) in ind . For example, consider v = rand(1, 10); Advanced Functions
Background image of page 2
User-Defined Functions Another type of m-file is a function file, which behave similar to the functions we used in C. Begin with a function definition line . This is the main difference between a function m-file and a script m-file. function [output variables] = function_name( input variables) where [ output variables] are a list of the values returned by the function function_name is the identifier used to call the function [ input variables] are a list of input values
Background image of page 3

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

View Full DocumentRight Arrow Icon
Function Example Write a function that computes the speed and distance traveled of a falling object where: This function should accept a vector input for t and return a vector of the speed and distance fallen for each of those times.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/06/2010 for the course ENGR 3 taught by Professor Ben-yaakov during the Summer '08 term at UCSB.

Page1 / 13

class_notes17 - Engineering 3 Class 17 Today: functions in...

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

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