22
Add to your agenda! Discovery Day. Wednesday, April 3 rd – all day Poster Presentation (Cafeteria) & Slide presentations (COA Atrium). For example: “Formula Hybrid High Voltage System” “Development of Next Generation IPMC Actuator for Flapping Wing UAV” “Mt. Everest Skydiving Research” “Tolerance for Ambiguity of Air Traffic Management Students” • TOMORROW! Wednesday, April 3 rd , 7PM, IC Auditorium “Innovation: Risk are necessary!” COE Forum. Monday, April 8th, 6PM, Lehman Atrium free food! Each college has representatives on the SGA and they host a forum for their college. Answer questions, give opinions! Arts & Science, Aviation. Business, Engineering 1 Dr. Mote

Add to your agenda!

  • Upload
    zhen

  • View
    40

  • Download
    2

Embed Size (px)

DESCRIPTION

Add to your agenda!. Discovery Day. Wednesday, April 3 rd – all day Poster Presentation (Cafeteria) & Slide presentations (COA Atrium). For example: “Formula Hybrid High Voltage System” “Development of Next Generation IPMC Actuator for Flapping Wing UAV” “Mt. Everest Skydiving Research” - PowerPoint PPT Presentation

Citation preview

Page 1: Add to your agenda!

1

Add to your agenda!

• Discovery Day. Wednesday, April 3rd – all day– Poster Presentation (Cafeteria) & Slide presentations (COA Atrium). For example:

• “Formula Hybrid High Voltage System”• “Development of Next Generation IPMC Actuator for Flapping Wing UAV”• “Mt. Everest Skydiving Research”• “Tolerance for Ambiguity of Air Traffic Management Students”

• TOMORROW! Wednesday, April 3rd, 7PM, IC Auditorium– “Innovation: Risk are necessary!”

• COE Forum. Monday, April 8th, 6PM, Lehman Atrium– free food!– Each college has representatives on the SGA and they host a forum for their college.

Answer questions, give opinions!• Arts & Science, Aviation. Business, Engineering

Dr. Mote

Page 2: Add to your agenda!

Programmer-DefinedFunctions (2)

1. Basics & Advantages2. Vocabulary & Order MATLAB follows3. Review of the general syntax (i.e. setup)4. Full example

2

Page 3: Add to your agenda!

3

1. BASICS

• A function is nothing but a “keyword”

– If that keyword is MATLAB’s, it is a “built-in” function

– If the programmer (you) created the .m file associated with the keyword, it is a “programmer-defined” function

Page 4: Add to your agenda!

1. Review of advantages

1. Focus2. Independence (they can be tested separately)3. Memory efficiency4. Easier to debug the overall code5. Clarity6. Re-usability7. Modularity

4

Page 5: Add to your agenda!

1. “dis”-advantage

Only 1 disadvantage:

a lot more .m files within your directory

5

Page 6: Add to your agenda!

2. Review of vocabulary

• Main script file: The script file that contains the original overall project.

• Function definition: the function header and the actual lines of code the function has to execute. (a little file for each new keyword)

• Function call: the command that calls upon the execution of the code that is inside the function definition– Usually placed within the main script file, but can also be within another function

definition. (A function CAN call another function you made!)

• Passing arguments: giving inputs to the function definition.

• Return info: final variables that the function definition calculated and gives back

• Collection variables: The variables which receive the return info

6

Function definition

Main script file

Function call, pass arguments

Return info

Variable = …

Page 7: Add to your agenda!

7

Vocabulary is important!

“Function call”

Professors & tutors will use these words! (instead of the “thingy”)

“Function parameters” (5)

Passed “arguments” (2)

“Return-info”

Collecting the “Return-value”

50 lines of “documentation”

“Function file”

In a ain script OR another function file ORthe command window!

444 lines of code!

Page 8: Add to your agenda!

Common mistake

• The “function call” is NOT the “function’s name”

8

This file is the “function

definition”

Here are 3 examples of

“function calls”

The name of the function is changeToLetter()

regardless!!!!!

Page 9: Add to your agenda!

9

Order MATLAB follows to communicate

Execute 444 lines of code!

Pass the arguments.Replaces the parameters.

Assign a value to the return-info

Answer = ….

“Return” the info

Collect the returned value

Page 10: Add to your agenda!

3. General Syntax

• In a separate .m file:

• Variables used in return-info, parameters, collecting return values, and arguments can be: Hardcoded (example: 32) Variables (example: age)

10

function <return info> = <function name>(<parameters>)% <documentation/help>

% <author etc..>

<function body>

1.2.

..

Numerical values Strings Numerical Arrays Cell-Arrays … anything!

Page 11: Add to your agenda!

11

Example: askForValidate.m

• Re-usability

Any questions overall?

Page 12: Add to your agenda!

8. Application: Shortening Codes!

Travelling Delays? Who/What’s to blame???

12

http://www.transtats.bts.gov/OT_Delay/OT_DelayCause1.asp?pn=1

Page 13: Add to your agenda!

13

8. Application: Shortening Codes!

• Excel sheets. Arriving Flights/Delayed Flights/Reasons

..2010201120122013

Page 14: Add to your agenda!

21 columns.. Only a few useful today

14

1, 2 Year and month3, 4 Carrier and its name5, 6 Airport, and its name7 arr_flights Count of flights8 arr_del15 Count of flights delayed (>15minutes)

9 carrier_ctLate due to carrier (maintenance or crew problems, aircraft cleaning, baggage loading, fueling, etc)

10 weather_ct Late due to weather (Significant meteorological conditions )

11 nas_ctLate due to National Aviation Delay System (non-extreme weather conditions, airport operations, heavy traffic volume, and air traffic control)

12 security_ct

Late due to evacuation of a terminal or concourse, re-boarding of aircraft because of security breach, inoperative screening equipment and/or long lines in excess of 29 minutes at screening areas

13 late_aircraft_ctA previous flight with same aircraft arrived late, causing the present flight to depart late.

14 arr_cancelled Count of aircraft cancelled15 arr_diverted Count of aircrafts diverted16 arr_delay17 carrier_delay18 weather_delay19 nas_delay20 security_delay21 late_aircraft_delay

Page 15: Add to your agenda!

Solve for..

1. Percentage of flights delayed1. Percentage of those flights delayed due to carrier’s fault2. Percentage of those flights delayed due to weather 3. Percentage of those flights delayed due to NAS4. Percentage of those flights delayed due to security5. Percentage of those flights delayed due to late flights

2. Percentage of flights arrived on time

3. Present result in table4. If time, present results in pie chart

15

Page 16: Add to your agenda!

2 Functions to create

[nbs, headings]=extractCorrectData(fileChosen);Depending on the file chosen (2010? 2009?...), get rid of all the lines that have blanks, and only return the nbs and the headings needed.

flights_on_time = analyze(headings, nbs);Given the headings and numbers needed, calculate all percentages and display in a table. Calculate and return the % of flights on time.

16

Page 17: Add to your agenda!

extractCorrectData.mfunction [nbs, headings]=extractCorrectData(fileChosen)%USE AS: [nbs, headings]=extractCorrectData(fileChosen); % Depending on the file chosen (2010? 2009?...), get rid % of all the lines that have blanks, and only return the % nbs and the headings needed.

% by <author goes here>

17

Page 18: Add to your agenda!

extractCorrectData.mfunction on_time = analyze(headings, nbs)%USE AS: on_time = analyze(headings, nbs);% Given the headings and numbers needed, calculate all percentages and % display in a table. Calculate and return the % of flights on time.

% by <author would go here>

18

Page 19: Add to your agenda!

Main file%Airline On-Time Statistics and Delay Causes%by Caroline %http://www.transtats.bts.gov/OT_Delay/OT_DelayCause1.asp?pn=1 clcclear repeat = 1; %force loop to startwhile repeat ==1 clc %let user pick file myFile = uigetfile('*.*'); %get rid of bad data, and useless columns %calculate percentages/display table %show year and flight on time year = fprintf('Flights were %.2f%% on time in %s.\n',flights_on_time,year) %ask user to repeat repeat = input('Choose another file? (1 for yes, anything else quits): ');end 19

Page 20: Add to your agenda!

Online App shows ALL data

• I just wanted to focus on the “not on time”

20

Page 21: Add to your agenda!

Quick reminder

• sum(matrix) sums each COLUMN.

x =

17 19 6 20 19 13 11 4 3 2 20 20

>> sum(x)

ans =

39 34 37 44

21

Page 22: Add to your agenda!

Improvements?

• Note how LONG it takes for MATLAB to process excel sheets.• How about combining ALL years into 1 xls sheet?

>> memory issues• How about putting each year into a separate sheet?• Giving the user the possibility to analyze only 1 airline?

22