General Computer Science for Engineers CISC 106 Lecture 12 Roger Craig Computer and Information Sciences 3/11/2009.

Slides:



Advertisements
Similar presentations
User-Defined Functions Like short programs Can operate on their own data Can receive data from callers and return data to callers.
Advertisements

Two-Dimensional Arrays Chapter What is a two-dimensional array? A two-dimensional array has “rows” and “columns,” and can be thought of as a series.
General Computer Science for Engineers CISC 106 Lecture 01 James Atlas Computer and Information Sciences 9/2/2009.
Chapter 1 Computing Tools Data Representation, Accuracy and Precision Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
General Computer Science for Engineers CISC 106 Lecture 28 Dr. John Cavazos Computer and Information Sciences 04/29/2009.
General Computer Science for Engineers CISC 106 Lecture 02 James Atlas Computer and Information Sciences 6/10/2009.
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
General Computer Science for Engineers CISC 106 Lecture 04 Roger Craig Computer and Information Sciences 9/11/2009.
General Computer Science for Engineers CISC 106 Final Exam Review Dr. John Cavazos Computer and Information Sciences 05/18/2009.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
General Computer Science for Engineers CISC 106 Lecture 10 Roger Craig Computer and Information Sciences 3/06/2009.
CS101- Lecture 11 CS101 Fall 2004 Course Introduction Professor Douglas Moody –Monday – 12:00-1:40 – – –Web Site: websupport1.citytech.cuny.edu.
General Computer Science for Engineers CISC 106 Lecture 25 Dr. John Cavazos Computer and Information Sciences 04/20/2009.
General Computer Science for Engineers CISC 106 Lecture 13 Roger Craig Computer and Information Sciences 3/13/2009.
General Computer Science for Engineers CISC 106 Lecture 09 James Atlas Computer and Information Sciences 9/25/2009.
General Computer Science for Engineers CISC 106 Lecture 05 Dr. John Cavazos Computer and Information Sciences 2/20/2009.
General Computer Science for Engineers CISC 106 Lecture 18 Dr. John Cavazos Computer and Information Sciences 3/27/2009.
General Computer Science for Engineers CISC 106 Lecture 06 Roger Craig Computer and Information Sciences 2/23/2009.
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
IE 212: Computational Methods for Industrial Engineering
General Computer Science for Engineers CISC 106 Lecture 07 James Atlas Computer and Information Sciences 06/29/2009.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
COIT29222 Structured Programming Slide 1 COIT29222-Structured Programming Lecture Week 06  Reading: Study Guide Book 2, Modules 9 & 10 Textbook (4 th.
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.
CSC Intro. to Computing Lecture 13: PALGO. Announcements Midterm is in one week  Time to start reviewing  We will do more review in class Tuesday.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Agenda Review C++ Library Functions Review User Input Making your own functions Exam #1 Next Week Reading: Chapter 3.
CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.
Today’s lecture 2-Dimensional indexing Color Format Thread Synchronization within for- loops Shared Memory Tiling Review example programs Using Printf.
Synthesis ENGR 1181 MATLAB 11. Topics  No new material  Covers topics that will be on the Midterm 2 Exam MATLAB 01 – Program Design MATLAB 02 – Introduction.
Introduction to Unix – CS 21
CSC 221: Computer Programming I Fall 2001 course overview  what did we set out to learn?  what did you actually learn?  where do you go from here? 
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 2/13/2009.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 11 – How to Get Started on Assignment #2 Webpage:
General Computer Science for Engineers CISC 106 Lecture 2^4 Roger Craig Computer and Information Sciences 03/23/2009.
CSC 1010 Programming for All Lecture 4 Loops Some material based on material from Marty Stepp, Instructor, University of Washington.
Week 61 Introduction to Programming Ms. Knudtzon C Period Tuesday October 12.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
General Computer Science for Engineers CISC 106 Lecture 13 - Midterm Review James Atlas Computer and Information Sciences 10/02/2009.
General Computer Science for Engineers CISC 106 Lecture 15 Dr. John Cavazos Computer and Information Sciences 03/16/2009.
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
General Computer Science for Engineers CISC 106 Lecture 14 James Atlas Computer and Information Sciences 08/10/2009.
General Computer Science for Engineers CISC 106 Lecture 05 James Atlas Computer and Information Sciences 6/22/2009.
1 st Semester Module 7 Arrays อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering Department.
Bubble sort. Quite slow, but simple Principles: Compare 2 numbers next to each other (lets call it current and the one next to it) If the current number.
1 Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
Lab 7 Shell Script Reference: Linux Shell Scripting Tutorial v1.05r3 A Beginner's handbook
General Computer Science for Engineers CISC 106 Lecture 27 Dr. John Cavazos Computer and Information Sciences 04/27/2009.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
Next Week… Quiz 2 next week: –All Python –Up to this Friday’s lecture: Expressions Console I/O Conditionals while Loops Assignment 2 (due Feb. 12) topics:
Lecture 7 Introduction to Shell Programming
Lecture 7 Introduction to Shell Scripts COP 3353 Introduction to UNIX.
Topics Introduction to Repetition Structures
Intro to Programming Week # 6 Repetition Structure Lecture # 10
Writing Shell Scripts ─ part 3
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
CISC101 Reminders Quiz 1 grading underway Next Quiz, next week.
CSCI The UNIX System Shell: Aliases
Communication and Coding Theory Lab(CS491)
CISC124 Labs start this week in JEFF 155.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
by Joe Michael Allen, Frank Vahid, Kelly Downey, and Alex Edgcomb
Using Script Files and Managing Data
CS150 Introduction to Computer Science 1
CISC101 Reminders Quiz 1 marking underway.
Matlab Basics Tutorial
General Computer Science for Engineers CISC 106 Lecture 11
Presentation transcript:

General Computer Science for Engineers CISC 106 Lecture 12 Roger Craig Computer and Information Sciences 3/11/2009

Lecture Overview Midterm in one week (3/18) Review next Tuesday 4:30pm) Friday: Hand out review sheet Changing your shell Matrix loops cont.

What is the return value of this function G, for the following code? x = 3; function output = G(x) output = x^2; End A.output B.9 C.3 D.x^2 E.None of the above

What are the input parameters for this function? function [ output, output2] = hi() fprintf(‘Hello World\n’) [output, output2 ] = [2 3]; End A.input B.output C.‘Hello World’ D.0 E.None of the above

Changing your shell Go to Sign in and choose: Change your UNIX Login Shell You are recommended by the department to use the csh shell Personally, I use the bash shell

Matrix looping cont. function [output] = change8to9( inputMatrix) %changes the first 8 in each row to a 9 in a matrix and returns that altered matrix %input: matrix %output: matrix lengths = size(inputMatrix); %get size of matrix and store in 1x2 array fprintf('size of the matrix m by n is ') disp(lengths) for m = 1:lengths(1) for n = 1:lengths(2) if (inputMatrix(m,n) == 8) %if that position equals an 8 inputMatrix(m,n) = 9; %change that position in the matrix to a 9 using an assignment statement break; %break out of this inner FOR loop end %ends the IF end %ends the inner FOR loop end %ends the outer FOR loop output = inputMatrix; %assign the matrix to the output value (or in other words, "return the (possibly) altered matrix") end %end the function Note:this code is found on the course website under Examples

For loop and break statement break; lets us stop a for loop before it would normally stop However, break; statement makes for unclear code and should be avoided What to use instead? While or do loop Next lecture

Conclusion Understand what every function’s input and output parameters are Use a good shell. The command line, while slightly less user friendly, is much more powerful and ergonomic for almost all tasks Know how to loop through a vector, and by extension, a matrix (which can be thought of as a series of vectors side by side)