1 CS100J April 28 2005 Course evaluation. Please complete the online course evaluation form for CS100J. It does indeed help us improve the course. Completion.

Slides:



Advertisements
Similar presentations
Jeopardy $100 $100 $100 $100 $100 $200 $200 $200 $200 $200 $300 $300
Advertisements

Advanced use of functions Anonymous functions function handles subfunctions and nested functions.
1 Various Methods of Populating Arrays Randomly generated integers.
General Computer Science for Engineers CISC 106 Lecture 01 James Atlas Computer and Information Sciences 9/2/2009.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1 ; Programmer-Defined Functions Two components of a function definition.
Basic Programming II. Outline Standard Deviation Function (SD) Complex Guessing Game.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect FXP. 1Winter Quarter Course Wrap Up and.
Introduction to Matlab. I use Matlab for: Data analysis Data plotting Image Analysis Also – Simulations (solving odes/pdes/finite element methods) – Minimisations,
Lecture 5 Review Programming Program Structures Comparison Repetition: looping or iteration Conditional execution: branching Bubble Sort.
CSci 2031: Matlab Tutorial Guoquan (Paul) Huang Jan 24, 2008.
Lecture 6 MATLAB functions Basics of Built-in Functions, Help Feature, Elementary Functions (e.g., Polynomials, Trigonometric Functions), Data Analysis,
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
1 G:\common\eng1102\1102_200508\02matlab\m10.functions.sxi Today's Agenda ● Introduce Matlab User Functions.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect FXP. 1Winter Quarter Course Wrap Up and.
Introduction to MATLAB ENGR 1187 MATLAB 1. Programming In The Real World Programming is a powerful tool for solving problems in every day industry settings.
M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files called M- files. M-files are.
Functions 1 parameter, 2 return-values "Conversion of time format" One problem. 5 steps to solve it. 1.
General Computer Science for Engineers CISC 106 Lecture 07 James Atlas Computer and Information Sciences 06/29/2009.
Recap Graphic Window Edit Window Start Button Matrices in MATLAB Scalar Operations Order of Operations Array Operations Matrix Addition Matrix Multiplication.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Hydroinformatics: Session4 Dr Ivan Stoianov Room 328B Dr Andrew Ireson (Room 304) Mr Juan Rodriguez-Sanchez (411A) Mr Baback.
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
Mean and Standard Deviation of Grouped Data Make a frequency table Compute the midpoint (x) for each class. Count the number of entries in each class (f).
1 Lab of COMP 319 Lab tutor : Yao Zhang, Shenghua ZHONG Lab 4: Nov 30, 2011 Final Project: Image Compression.
General Computer Science for Engineers CISC 106 Lecture 01 James Atlas Computer and Information Sciences 6/8/2009.
Function M-File Numerical Computing with. MATLAB for Scientists and Engineers.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
Advanced Topics- Functions Introduction to MATLAB 7 Engineering 161.
COMP 116: Introduction to Scientific Programming Lecture 11: Functions.
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Logic and Control. 4-2 Decision (selection) structure: if (condition) { statement etc. } Example: if (age == 15) { document.write(“ you are a fifteen”);
Chapter 6 Review: User Defined Functions Introduction to MATLAB 7 Engineering 161.
Lecture 05 Functions II, Storage Class, Scope, rand() METU Dept. of Computer Eng. Summer 2002 Ceng230 - Section 01 Introduction To C Programming by Ahmet.
1 CS100J 02 May Matlab and PI and other things The notation j:k gives a row matrix consisting of the integers from j through k. The notation j:k gives.
Analyzing Functions (4.16) y=f(x) MATLAB. Functional Analysis includes: Plotting and evaluating a function Finding extreme points Finding the roots (zeros.
Repetition. Loops Allows the same set of instructions to be used over and over again Starts with the keyword loop and ends with end loop. This will create.
Chapter 3 Working with Batches of Data. Objectives Understand vector class and how it can be used to collect, store and manipulate data. Become familiar.
Digital Image Processing Introduction to M-function Programming.
Introduction to Matlab
An Introduction to Programming with C++ Sixth Edition Chapter 10 Void Functions.
ENG 1181 College of Engineering Engineering Education Innovation Center 1 Script File Input – Output : Chapter 4 PLEASE HAVE STUDENTS START MATLAB NOW.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
Matlab Tutorial 1 David Goldstein University of Colorado Dept of Aerospace Engineering Sciences.
SCRIPTS AND FUNCTIONS DAVID COOPER SUMMER Extensions MATLAB has two main extension types.m for functions and scripts and.mat for variable save files.
Manipulator example #include int main (void) { double x = ; streamsize prec = cout.precision(); cout
General Computer Science for Engineers CISC 106 Lecture 14 James Atlas Computer and Information Sciences 08/10/2009.
CS 100Lecture 231 CS100J Lecture 23 n Previous Lecture –MatLab and its implementation, continued. n This Lecture –MatLab demonstration.
ARRAYS Multidimensional realities Image courtesy of
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
User Defined Functions Spring EE 201. Class Learning Objectives  Achieve Comprehension LOL of User Defined Functions. Spring
CORRECTNESS ISSUES AND LOOP INVARIANTS Lecture 8 CS2110 – Fall 2014.
Copyright © Cengage Learning. All rights reserved. Section 3.1 Measures of Central Tendency: Mode, Median, and Mean.
Working with Batches of Data
MATLAB – More Script Files
User-Defined Functions
CS100J 26 April. Matlab Use help button!!! Variables, values, types
Programming in JavaScript
Introduction to Matlab LAB 4
Programming in JavaScript
Programming in JavaScript
CS100A Lecture 21 Previous Lecture This Lecture
Week 7: Computer Tools for Problem Solving and Critical Thinking
Presentation transcript:

1 CS100J April Course evaluation. Please complete the online course evaluation form for CS100J. It does indeed help us improve the course. Completion of the evaluation counts toward your course grade (1%, like a quiz), and we expect 100% you to complete it. After the submission period, we are sent a list of students who completed the evaluation. We do NOT know what you, as an individual, said.

2 About grades About grades. The CMS computes a total score for you, based on the weight we give to each part of the course. On the CMS, you see the weight, but not your total score! Future versions of CMS will show you your score. We will each of you your total score and the average total score soon. It will include everything except A5, A6, and the final. I do not formally curve the course grades based on median, standard deviation, etc. Last time I taught this course, the grades went like this: A: 35% B: 40% C: 24% I cannot tell what the percentages will be this time until I do the grading. The final counts a lot, as do the prelims.

3 Matlab functions Finding out the syntax of functions. Click the Help button in Matlab. In the window that opens, search for “functions”. M-files: scripts or functions. The M-file name, less its extension, is what MATLAB searches for when reference the script or function. If file containing a function is named bsearch.m, then you can call bsearch( arguments )

4 Functions bsearch % r is sorted. Store in h a value to truthify % r[1..h] <= x < r[h+1..nocols] function h= bsearch(r, x) nocols= length(r); h= 0; k= nocols + 1; % inv: r[1..h] <= x < r[k..nocols] while ( h+1 < k ) e= floor( (h+k)/2); if r(e) <= x h= e; else k= e; end specification Header. Parameters are r and x. Body stores result in variable h body Statement return; in the body term- inates execution of the body

5 Matlab functions % = [mean, standard deviation] of vector x function [mean,stdev] = stat(x) n= length(x); mean= sum(x)/n; stdev= sqrt(sum((x-mean).^2/n)); Result is an array of two values. Body has to assign to both mean and stdev. Put this function in file stat.m Function has one parameter: x

6 Subfunctions % = [mean, standard deviation] of vector x function [mean,stdev] = stat(x) n = length(x); mean = avg(x)/n; stdev = sqrt(sum((x-mean).^2/n)); % = sum of values of x divided by n function m = avg(x, n) m= sum(x)/n avg is a “subfunction”. Can be called only within this file.

7 Calculating pi using a dart board If you throw random darts at this dart board and they all hit it, what percentage of them do you expect will land in the red area?

8 Calculating pi using a dart board If you hit this dart board with random darts, what percentage of them will land in the red area? It’s a 2 x 2 square Area of square: 4 Area of circle: pi r*r = pi Area of circle with radius r: pi r*r pi/4 of them are expected to hit the dartboard!

9 Calculating pi using a dart board Percentage of darts expected to land in red area: pi/4 It’s a 1 x 1 square Area of square: 1 Area of ¼ of circle: pi/4 Area of circle with radius r: pi r*r x y (x,y) is in red area if x*x + y*y <= 1

10 Wallis ( ) approximation to pi (2*2) * (4*4) * (6*6) * … pi / 2 = (1*3) * (3*5) * (5*7) * … Euler ( ) approximation to pi pi*pi / 6 = 1/(1*1) + 1/(2*2) + 1/(3*3) + 1/(4*4) + …