ENG 06 – Lecture 9 notes.docx

4 Pages
37 Views

Department
Engineering
Course Code
ENG 6
Professor
A H M E D R A W Y

This preview shows page 1. Sign up to view the full 4 pages of the document.
Description
ENG 06 – Lecture 9; 2/5/2013 Project 1:  Read over tonight, have questions to ask this week (don’t wait) Custom Functions  Inline and Anonymous Functions o If you want to write a function that you’ll need for a few minutes o Not a good idea to use these regularly; not for big projects  Inline Function o Explicit definition of arguments  Inline(expr,arg1,arg2,…) constructs an inline function  Arguments specificed by strings  Anonymous Functions o Fhandle = @(arglist) expression  @ sign constructs function handle  arglist is comma separated list of input arguments  ex. log8 = @(x) log(x)/log(8)  Feval and Function handles o Use feval to call and evaluate other functions by their function handle o First input is function handle, calls function indirectly  Example of why Function Handles are Useful o function [] = funplot(fun, a, b, xlab, ylab)
 o % Makes a plot of function fun between the limits a and b and insert x label and y label as provided in xlab and ylab o x=linspace(a,b,100);
 o y=feval(fun,x);
 o plot(x,y);
 o xlabel(xlab); o ylabel(ylab);
 o end  funplots(@sin,0,pi,’xx’,’yy’) returns the answer  funplots(sin,0,pi,’xx’,’yy’) returns an error  Auto-code generation feature of MATLAB o >>x=linspace(1,10,30); o y1=sin(x) o y2=cos(x) o plot(x,y1,x,y2)  create graph  interactively modify graphs  auto generate code  Summary for functions o Functions defined in a file of the same name using key word function to distinguish from scripts o Parameters are copied in sequence into the function and given names of formal parameters o Results are returned to caller by assigning values to return variables o Variables within function have scope only in functions code block (unless they are declared global) o Helper functions are accessible only to functions within the same file may be added behind main function and obey the same rules as the main function Engineering Design  Relationship between Science, Engineering, and Technology o Science needs to understand natural world, often needs new tools o Engineers use scientific discovery to design products and process that meet society’s needs  Generic Engineering Design Cycle o Ask o Imagine o Plan o Create o Improve  NASA Case Study:Develop a Lunar plant growth chamber o Launched 10 million cinnamon basil seeds o Almost all seeds were returned to earth for students to grow in growth chambers they designed o 16 seeds were left, grown on the ship, to demonstrate growing plants in a microgravity environment  Detailed Engineering Design: o Identify the problem o Identify criteria and constraints o Brainstorm possible solutions o Generate ideas o Explore possibilities o Select an approach o Build a model or prototype o Refine the design  Design example: develop a lunar plant growth chamberd o Identify the problem: restate in your own words o ID: criteria and constraints: growth chamber must have surface of 10 square feet  Constraints: must be accessible to astronauts without leaving the spacecraft o Brainstorm possible solutions: sketch ideas, quick and brief o Generate ideas: develop 2 or 3 ideas more thoroughly, create new drawings o Explore possibilities: pros and cons of ideas o Select and approach: identify the design that appears to solve the proble
More Less
Unlock Document

Only page 1 are available for preview. Some parts have been intentionally blurred.

Unlock Document
You're Reading a Preview

Unlock to view full version

Unlock Document

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit