Engr 231 Lab 6

Engr 231 Lab 6 - Drexel University - ENGR 231 Linear...

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

View Full Document Right Arrow Icon
Drexel University - ENGR 231 Linear Engineering Systems, Fall 2011 Copyright 2011, Drexel University Page 1 Lab 6 – Functions and Advanced Homogeneous Transformations Goals: 1. Introduce the concepts of functions for code consolidation 2. Reinforce homogeneous coordinate transformations and composite transformations. Prelab - Function Basics Functions in MATLAB are analogous to commands. We have already seen a few of them such as sin, cos, and plot . Others, such as input and disp perform input/output operations. A function in programming syntax takes inputs, performs a given task or tasks, and then highlights the outputs. Fuctions in MATLAB are implemented as m-files with special code in its first line. The syntax of the first line of a function is as follows: function [out1, out2, . ..] = funcName(in1, in2, . ..) <command 1> <command 2> ... This becomes incredibly useful not only in simplifying code, but opens many doors to other concepts in MATLAB that we will get to at a later time. After the function is defined and saved, we may run the function either in a script or in the command window using the following syntax: [out1Val, out2Val, . ..] = funcName(in1Val, in2Val, . ..) IMPORTANT POINTS ABOUT FUNCTIONS: 1. The filename of a function MUST BE THE SAME AS THE FUNCTION NAME. 2. The first line of the function MUST follow the syntax described above. 3. When you run a function, you must be aware that your current working directory is set properly. The current working directory is specified at the top of the command window. If you don’t do this, then MATLAB won’t recognize your function (i.e. Undefined function or Variable error). 4.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/11/2011 for the course ENGR 231 taught by Professor Olehtretiak during the Fall '10 term at Drexel.

Page1 / 5

Engr 231 Lab 6 - Drexel University - ENGR 231 Linear...

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

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