March 2005 1R. Smith - University of St Thomas - Minnesota Today’s Class RecapRecap Schedule for rest of classesSchedule for rest of classes Matlab Functions.

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

Java Programming, 3e Concepts and Techniques Chapter 3 Section 63 – Manipulating Data Using Methods – Day 2.
March R. Smith - University of St Thomas - Minnesota Today’s Class Quiz RecapQuiz Recap Exam ReviewExam Review C MaterialC Material Matlab MaterialMatlab.
The Web Warrior Guide to Web Design Technologies
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
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.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Reviewing previous workReviewing previous work Using a dialog boxUsing.
©2004 Brooks/Cole Chapter 1: Getting Started Sections Covered: 1.1Introduction to Programming 1.2Constructing a Java Program 1.3The print() and println()
Spring R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Return HomeworkReturn Homework Class ScheduleClass Schedule Functions:
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
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 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 Today’s Class Office hours canceled todayOffice hours canceled today RecapRecap Matlab ProgrammingMatlab.
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 /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.
Lesson 4 Computer Software
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Introduction to Python
9/21/2015 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class RecapRecap Files, writing filesFiles, writing files 1D Array Recap1D.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
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.
Computer Science 101 Introduction to Programming.
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.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Grades & Lab 12Grades & Lab 12 Upcoming ExamUpcoming Exam StructuresStructures.
March R. Smith - University of St Thomas - Minnesota QMCS Class Today “Enigma” recap and finish“Enigma” recap and finish The quiz/surveyThe.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
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.
Introduction to LISP Atoms, Lists Math. LISP n LISt Processing n Function model –Program = function definition –Give arguments –Returns values n Mathematical.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
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 R. Smith - University of St Thomas - Minnesota Today’s Class Class StuffClass Stuff ProjectProject Vectors and DimensionsVectors and Dimensions.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
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:
MATLAB: Structures and File I/O
T. Jumana Abu Shmais – AOU - Riyadh
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Javascript Chapter 19 and 20 5/3/2019.
Presentation transcript:

March R. Smith - University of St Thomas - Minnesota Today’s Class RecapRecap Schedule for rest of classesSchedule for rest of classes Matlab Functions and Control StructuresMatlab Functions and Control Structures Matlab and C on the ExamMatlab and C on the Exam

March R. Smith - University of St Thomas - Minnesota Recap Homework GradedHomework Graded Hard DrivesHard Drives File StructureFile Structure File NamesFile Names Matlab ScriptsMatlab Scripts

Schedule Today is the Last Lecture – rest will be labsToday is the Last Lecture – rest will be labs Final schedule is posted on the web pageFinal schedule is posted on the web page Extra lab time this Friday, same time as classExtra lab time this Friday, same time as class Assignment 15 due MondayAssignment 15 due Monday Projects Demonstrated next ThursdayProjects Demonstrated next Thursday Extra lab day Next FridayExtra lab day Next Friday Assignment 16 due Exam DayAssignment 16 due Exam Day March R. Smith - University of St Thomas - Minnesota

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

Matlab and Search Paths You can rename built in functionsYou can rename built in functions –You can control which functions get used: builtins or cusom Look at ‘Search Paths’ box under ‘File’ menuLook at ‘Search Paths’ box under ‘File’ menu –Can control the order lookfor commandlookfor command –Tells you which version of a function you are using March R. Smith - University of St Thomas - Minnesota

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 MinmaxMinmax 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

FOR THE EXAM Any numerical or text-oriented function you can write in C, you should be able to write in Matlab!Any numerical or text-oriented function you can write in C, you should be able to write in Matlab! And Vice Versa!And Vice Versa! Text string examples:Text string examples: –copy, append, find or replace a character, compare strings Arithmetic examples:Arithmetic examples: –sum, min, max, average, sigma-based things March R. Smith - University of St Thomas - Minnesota

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.