ENGR112 HW4 Functions.pdf - Week 4 Homework Name Will...

This preview shows page 1 - 7 out of 20 pages.

Week 4 Homework ENGR 112 Functions By writing or typing your name below you affirm that all of the work contained herein is your own, and was not copied or copied and altered. Will Frisch Note: Failure to sign this page will result in a 50-point penalty. Failure to list people you worked with may result in no grade for this homework. Failure to fill out hours approximation will result in a 10-point penalty. Name: Will Frisch Lab Time: Ecampus Names of people you worked with: N/A (Ecampus) Websites you used: • Zybooks Textbook, Canvas Notes Approximately how many hours did it take you to complete this assignment (to nearest whole number)? 6 hours
Week 4 Homework ENGR 112 Functions Turn .zip files to Canvas or your assignment will not be graded
Week 4 Homework ENGR 112 Functions Learning Objectives: Practice with loops and if statements. How to create a function file. How to create an anonymous function. How to use functions as inputs to other functions Homework Guidelines: 1) Functions are a way to encapsulate functionality, and to reduce errors caused by copying code. From this homework on you should be using functions (either anonymous or function files) for writing equations, and for loops to avoid duplicating code. 2) Whenever you create a function you must decide what goes into the function, and what goes into the calling script. For example, do you pass gravity in as a variable or do you just set it in the function? Document your choices. 3) Debugging: Set a break point at the first line of your function file. This way, you can see what happens in the function file. First, check that the parameters that got passed in have the values you expect. Second, make sure the output variable(s) are set correctly. Grading Checkpoints Criteria Component No Yes [20%] Comments and Pseudocode Declared units on all variables? English description of problem at top? Comments outlining your steps? [10%] Output formatting Used fprintf() to make complete sentences (when required)? Correct units on answers? Correct number of decimal places? [70%] Functionality Script computes correct value(s)? Correctly converted units in script when needed? Accomplished all functionality in the problem
Week 4 Homework ENGR 112 Functions
Week 4 Homework ENGR 112 Functions For 1) and 2), please write which homework problem it is in the comments box. You must re-do a different problem for 1) and 2). Bonus [up to +10 each]: Add more complex functionality to the original problem by, for example, using a for loop, plotting it in a different way, searching for a minimum value, etc. Make sure you clearly document what changes you made. Problem 1 Pick any one of the previous homework problems and re-do it with an anonymous function. Comments for grader/additional information (if any) Homework 2, Problem 1 Extra changes you made: none Script File
Week 4 Homework ENGR 112 Functions %Will Frisch, 10/15/19 clear;clc;close;clf; %clears the graphs, command window, & variables %Initial boundaries a = -10:0.004:7; %boundary for "x"(seconds) %Functions & Variables AnonFunc = @(x) 4.*x.^3+3.*x.^2+5.*x+5;

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture