March 2005 1R. Smith - University of St Thomas - Minnesota Today’s Class Office hours canceled todayOffice hours canceled today RecapRecap Matlab ProgrammingMatlab.

Slides:



Advertisements
Similar presentations
March R. Smith - University of St Thomas - Minnesota Today’s Class Quiz RecapQuiz Recap Exam ReviewExam Review C MaterialC Material Matlab MaterialMatlab.
Advertisements

Programming in Visual Basic
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
COSC 120 Computer Programming
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Vectors and DimensionsVectors and Dimensions Scripts (shell scripts)Scripts.
March R. Smith - University of St Thomas - Minnesota Today’s Class Recap of a simple programRecap of a simple program A “history” of CA “history”
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Hard Drives – more laterHard Drives – more later MethodsMethods.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class The project assignment, againThe project assignment, again Arrays.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Functions and Array ArgumentsFunctions and Array Arguments ExamExam.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
March R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class Class on Wednesday – “Lab time” in OSS 230Class on Wednesday – “Lab.
March R. Smith - University of St Thomas - Minnesota Today’s Class RecapRecap More course thingsMore course things Work on labs/projectsWork on labs/projects.
Spring R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Where we areWhere we are Strings and TextStrings and Text ConditionalsConditionals.
Spring R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Final Exam ReviewFinal Exam Review –Assessment –Exam Format –C –Matlab.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Exam StatusExam Status Recap of Lab 7 ExampleRecap of Lab 7 Example.
Spring R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Return HomeworkReturn Homework Class ScheduleClass Schedule Functions:
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Upcoming Exam – April 8Upcoming Exam – April 8 Structures ReviewStructures.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class RecapRecap Functions and CFunctions and C Using FunctionsUsing Functions.
CSC 171 – FALL 2004 COMPUTER PROGRAMMING LECTURE 0 ADMINISTRATION.
March R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class More “Clarifications” ?More “Clarifications” ? Interrupts – integrating.
March R. Smith - University of St Thomas - Minnesota Today’s Class First, course surveysFirst, course surveys RecapRecap More course thingsMore course.
6/28/2015 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class History Paper recapHistory Paper recap Finish the movieFinish the movie.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Data IndependenceData Independence Matlab #3: Exercise 5.1Matlab #3:
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class StatusStatus –Survey –Returning homework ArraysArrays –What are they?
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Finish up Lab 13Finish up Lab 13 Lab 14 – DetailsLab 14 – Details.
March R. Smith - University of St Thomas - Minnesota Today’s Class Class StuffClass Stuff ProjectProject Vectors and DimensionsVectors and Dimensions.
March R. Smith - University of St Thomas - Minnesota ENGR 330: Today’s Class Administrative: do you want another lab?Administrative: do you want.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Matlab “Matrix Laboratory”Matlab “Matrix Laboratory” Chapter 1 – matrices.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class About HomeworkAbout Homework Increment/DecrementIncrement/Decrement.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Homework & GradesHomework & Grades Multiple DimensionsMultiple Dimensions.
March R. Smith - University of St Thomas - Minnesota Today’s Class Homework NotesHomework Notes –Always try to match the printed output if I give.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Change in order of topicsChange in order of topics –Starting Chapter.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class The ExamThe Exam Homework NotesHomework Notes.
CIS101 Introduction to Computing Week 09 Spring 2004.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class AssignmentsAssignments Logical operationsLogical operations Summations.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
Computer Science 101 Introduction to Programming.
Chapter 9 Interactive Multimedia Authoring with Flash - Introduction to Programming “Computers and Creativity” Richard D. Webster, COSC 109 Instructor.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
March R. Smith - University of St Thomas - Minnesota Today’s Class RecapRecap Schedule for rest of classesSchedule for rest of classes Matlab Functions.
9/21/2015 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class RecapRecap Files, writing filesFiles, writing files 1D Array Recap1D.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
Introduction to MATLAB Session 3 Simopekka Vänskä, THL Department of Mathematics and Statistics University of Helsinki 2011.
Spring R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Final Exam – rest of class scheduleFinal Exam – rest of class schedule.
5/27/2016 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class RecapRecap Drawing in 2 dimensionsDrawing in 2 dimensions Vertical HistogramVertical.
6/3/2016 CSI Chapter 02 1 Introduction of Flow of Control There are times when you need to vary the way your program executes based on given input.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Grades & Lab 12Grades & Lab 12 Upcoming ExamUpcoming Exam StructuresStructures.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Intermediate 2 Computing Unit 2 - Software Development.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
1/7/2016 1R. Smith - University of St Thomas - Minnesota Today’s Class Mostly Lab TimeMostly Lab Time How to use shared foldersHow to use shared folders.
1/28/2016 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class Assignments 7 and 8Assignments 7 and 8 ExamExam History Paper AssignmentHistory.
2/22/2016 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class History Paper scheduleHistory Paper schedule RecapRecap Plus PlusPlus.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class What’s on the Exam Next Week?What’s on the Exam Next Week? Lab 8Lab.
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 1 Scott Marino.
March R. Smith - University of St Thomas - Minnesota Today’s Class Class StuffClass Stuff ProjectProject Vectors and DimensionsVectors and Dimensions.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Chapter 1: Introduction to Computers and Programming.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
7/6/2016 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class Collect PapersCollect Papers Review: Our ZeroesReview: Our Zeroes Review:
7/6/2016 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class Computer HardwareComputer Hardware Recap: next programRecap: next program.
MatLab Programming By Kishan Kathiriya.
Javascript Chapter 19 and 20 5/3/2019.
Presentation transcript:

March R. Smith - University of St Thomas - Minnesota Today’s Class Office hours canceled todayOffice hours canceled today RecapRecap Matlab ProgrammingMatlab Programming –Functions –IF/Then –Loops Assignment 16Assignment 16 Why C? Why Matlab?Why C? Why Matlab? Lab TimeLab Time

March R. Smith - University of St Thomas - Minnesota Recap of Yesterday Course ScheduleCourse Schedule –Extra credit Quiz If you have questions about answers on the last examIf you have questions about answers on the last exam –ASK ME DURING THIS LAB PERIOD –Review on Wednesday –Demos on Thursday –Last Matlab homework due Exam Week Do it BEFORE the exam as part of your studying!Do it BEFORE the exam as part of your studying! Work on labs/projectsWork on labs/projects

March R. Smith - University of St Thomas - Minnesota Matlab Functions Syntax:Syntax: function answers = name ( arguments ) % comment on how to use it statements ; File name.m must match function nameFile name.m must match function name List of zero or more arguments separated by commasList of zero or more arguments separated by commas May define answers as a list of valuesMay define answers as a list of values –function [min, max] = minmax (vect) –could find both min and max values of the vector vect Must set answers to legitimate valuesMust set answers to legitimate values Executes statements till the end of the function fileExecutes statements till the end of the function file

March R. Smith - University of St Thomas - Minnesota Function example Add some numbersAdd some numbers Return quotient and remainderReturn quotient and remainder The ‘help’ command for functionsThe ‘help’ command for functions

March R. Smith - University of St Thomas - Minnesota Matlab IF/Else Typical Syntax:Typical Syntax: if ( expression1 ) statement1 ; elseif ( expression2 ) statement2 ; else statement3 ; end ALWAYS needs the end statement to mark the endALWAYS needs the end statement to mark the end No curly bracesNo curly braces

March R. Smith - University of St Thomas - Minnesota IF Function Example True/false tests like even/oddTrue/false tests like even/odd Recursive FibonacciRecursive Fibonacci

March R. Smith - University of St Thomas - Minnesota Matlab FOR Syntax:Syntax: for variable = vector statements ; end Goes through vector, element by elementGoes through vector, element by element –Assigns an element to variable –The vector can be a colon statement, like 1:length(x) Runs the statements until end, then repeatsRuns the statements until end, then repeats ALWAYS needs the end statement to mark the endALWAYS needs the end statement to mark the end No curly bracesNo curly braces

March R. Smith - University of St Thomas - Minnesota For loop examples Sum of a vectorSum of a vector More efficient FibonacciMore efficient Fibonacci

March R. Smith - University of St Thomas - Minnesota Matlab WHILE Syntax:Syntax: while expression statements ; end Tests expression for non-zero result, loops if soTests expression for non-zero result, loops if so Runs the statements until end, then repeatsRuns the statements until end, then repeats ALWAYS needs the end statement to mark the endALWAYS needs the end statement to mark the end No curly bracesNo curly braces

March R. Smith - University of St Thomas - Minnesota Assignment 16 Do Kaplan's Exercises 8.5, and 8.6, on page the functions to the instructor.Do Kaplan's Exercises 8.5, and 8.6, on page the functions to the instructor. –Be sure to include COMMENTS FOR THE EXAMFOR THE EXAM –Any numerical or text-oriented function you can write in C, you should be able to write in Matlab! –Text string examples: copy, append, find a character, compare stringscopy, append, find a character, compare strings –Arithmetic examples: sum, min, max, average, sigma-based thingssum, min, max, average, sigma-based things

March R. Smith - University of St Thomas - Minnesota Why C? Why Matlab? The exam will ask you to explain why it’s better to use one or the other for various problemsThe exam will ask you to explain why it’s better to use one or the other for various problems

March R. Smith - University of St Thomas - Minnesota How is C different from Matlab? C is compiled; Matlab is interpretedC is compiled; Matlab is interpreted –A special program, the compiler, converts the C program from ASCII source code into binary coded computer instructions –In Matlab, the computer has to do that conversion whenever we type in an expression – we say Matlab is interpreted C Errors arise on two different occasionsC Errors arise on two different occasions –Syntax errors and some usage errors are found in compilation In a perfect world, this finds all possible errorsIn a perfect world, this finds all possible errors In practice, lots of errors slip through (a trade-off)In practice, lots of errors slip through (a trade-off) –Other errors arise when the program actually ‘runs’ Matlab errors only arise during executionMatlab errors only arise during execution –Errors may involve either syntax, logic, or both

March R. Smith - University of St Thomas - Minnesota Why is C popular? It is portableIt is portable –Easy to modify to create programs for another computer –The compiler itself is easily ‘hosted’ on other computers A fairly complete programming languageA fairly complete programming language –A rich set of data types and operations on them –Standard control structures, allows structured programming –Only missing object technology “Close to the machine”“Close to the machine” –Easy to write highly technical programs for operating systems –Mechanisms map easily to the machine level = efficient Highly efficient – optimizing compilersHighly efficient – optimizing compilers

March R. Smith - University of St Thomas - Minnesota Problems with C C programs can be hard to readC programs can be hard to read –Obfuscated C Contest Data types are not enforcedData types are not enforced –Compiler doesn’t catch every error it could Some operations have ‘side effects’Some operations have ‘side effects’ –Expressions don’t evaluate consistently to the same answer –In this class, we note and avoid operations with side effects Compared to MatlabCompared to Matlab –Requires more steps, more typing to yield a simple result –Unsophisticated output: no graphing –Rigid handling of input text – programmer must write code to interpret and process typed inputs

March R. Smith - University of St Thomas - Minnesota Who uses C today? Operating systemsOperating systems –Windows is mostly written in C –Linux/Unix is mostly written in C – that’s where C started –Macintosh software is mostly written in C –C++ is an object-oriented version that sees lots of use CompilersCompilers –C and C++ compilers are written in C Application packages, like ExcelApplication packages, like Excel –Many are being written in Java these days – GUIs are easier Embedded ApplicationsEmbedded Applications –Gas pumps, USB hubs, cell phones, lab equipment (!!!)

March R. Smith - University of St Thomas - Minnesota What about Matlab? It’s a proprietary commercial packageIt’s a proprietary commercial package –You have to buy it to use it, or borrow it from your school –C is available for free It is more flexible in handling numeric dataIt is more flexible in handling numeric data –Arrays can resize themselves to fit the data –Easy to add or remove elements or even dimensions Built in I/O to convert files to usable dataBuilt in I/O to convert files to usable data –C requires a lot of special code to read in data –Matlab converts files to vectors/matrices, all ready to use

March R. Smith - University of St Thomas - Minnesota Choosing between C and Matlab Matlab is Better for…Matlab is Better for… Vector and matrix mathVector and matrix math –When sizes aren’t known ahead of time Graphing – it’s built inGraphing – it’s built in Processing standard file formats – built inProcessing standard file formats – built in –Images and spreadsheets C is Better for… Group programming –Established ways of sharing the work Tight quarters –When the computer is too small to run Matlab Little or no OS support –Computer doesn’t have graphics, not very interactive Access to I/O hardware –Easy to manipulate I/O control registers from C

March R. Smith - University of St Thomas - Minnesota Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.