Programming Notes Study Guide
Programming Notes Study Guide BE1500
Popular in Intro to Programming
verified elite notetaker
Popular in Engineering and Tech
This 9 page Study Guide was uploaded by Neha Bhagirath on Wednesday June 15, 2016. The Study Guide belongs to BE1500 at Wayne State University taught by Tonya Whitehead in Spring 2016. Since its upload, it has received 26 views. For similar materials see Intro to Programming in Engineering and Tech at Wayne State University.
Reviews for Programming Notes Study Guide
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 06/15/16
Day 8 3 variables (2,3,4 line) and e and a are strings because e is in single quotes Base ten numbers are decimal numbers Binary numbers are base 10 (only 1 and 0, on or off) every binary has a unique decimal value how to convert from binary to decimal: EXAM REVIEW: 4 anonymous functions and 1 vector are the inputs so there are 5 inputs there are zero outputs are the anonymous functions always in the command window? If it says “the anonymous functions are going to be an input, then yes.” otherwise, it might say define them in your function anything you put in the command window, it is not known by the script so you must put any defined variables in the command window (like T=1) Day 9Exam review know how to do anonymous functions w/ multiple variables Question 1: Answer: Script: %p is the density %for two variables you need two defining input equations d=input('Enter a diameter of the tank: ') h=input('Enter a height of the tank: ') volume=1/3*pi*(d/2)^2*h; %replace r with d/2 %doesn't ask for an anonymous function so you do not need it weight=volume*62.3; %consider mass as weight, d=m/v display(volume) display(weight) Command Window: >> untitled6 Enter a diameter of the tank: 4 d = 4 Enter a height of the tank: 4 h = 4 volume = 16.7552 weight = 1.0438e+03 >> format compact >> untitled6 Enter a diameter of the tank: 4 d = 4 Enter a height of the tank: 4 h = 4 volume = 16.7552 weight = 1.0438e+03 Question 2: Answer: Script: %says in the question we have one input with 5 numbers function[sue]=untitled6(tim) a=tim(1); b=tim(2); c=tim(3); d=tim(4); e=tim(5); sue=(a+b+c+d+e)/5; %other option you can do is sue=mean(tim) which is more efficient; %other option is to do sue=(tim(1)+tim(2)+tim(3)+tim(4)+tim(5))/5; end Command Window: untitled6([2 4 6 8 10]) ans = 6 Question 3: Answer: Script: function [ output_args ] = untitled9( x1,y1,z1,x2,y2,z2) %UNTITLED9 Summary of this function goes here % Detailed explanation goes here d=((x2x1)^2+(y2y1)^2+(z2z1)^2)^(1/2) %distance calculation i (x1~=0) && (x2~=0) && (y1~=0) && (y2~=0) && (z1~=0) && (z2~=0) %the double and is like doing a semicolon at the end and it suppresses the calculation display'Points in 3D space') elseif(x1~=0) && (x2~=0) && (y1==0) && (y2==0) && (z1==0) && (z2==0) display'Points along the xaxis') elseif(y1~=0) && (y2~=0) && (x1==0) && (x2==0) && (z1==0) && (z2==0) display'Points along the yaxis') elseif(z1~=0) && (z2~=0) && (y1==0) && (y2==0) && (x1==0) && (x2==0) display'Points along the zaxis') elsei(x1==0) && (x2==0) display'Points within yz plan) elsei(y1==0) && (y2==0) display'Points within xz plan) elsei(z1==0) && (z2==0) display'Points within xy plan) end end %need two end statements for a function or switchcase with elseif Command Window: untitled9(1,2,3,12,13,14) d = 19.0526 Points in 3D space >>
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'