March 2005 1R. Smith - University of St Thomas - Minnesota Today’s Class Class StuffClass Stuff ProjectProject Vectors and DimensionsVectors and Dimensions.

Slides:



Advertisements
Similar presentations
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
Advertisements

March R. Smith - University of St Thomas - Minnesota Today’s Class Quiz RecapQuiz Recap Exam ReviewExam Review C MaterialC Material Matlab MaterialMatlab.
March R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Tomorrow’s ExamTomorrow’s Exam Today’s LabToday’s Lab SortingSorting.
March R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class ProjectsProjects 2 dimensional arrays2 dimensional arrays Higher dimensionsHigher.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Three exam questionsThree exam questions Lab with filesLab with.
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 QMCS 230: Today in Class Lab 16Lab 16 Filling in an arrayFilling in an array Searching for a.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class More about FunctionsMore about Functions RecursionRecursion.
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 IF StatementIF Statement Revisiting assignment statementsRevisiting.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Hard Drives – more laterHard Drives – more later MethodsMethods.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Exam TopicsExam Topics.
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.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Today: covering through P. 83 of textToday: covering through P. 83 of.
March R. Smith - University of St Thomas - Minnesota Today’s Class Course StuffCourse Stuff –Classroom change TOMORROW –Assignment; Lab While LoopsWhile.
March R. Smith - University of St Thomas - Minnesota Today’s Class Program LayoutProgram Layout Problem SolvingProblem Solving Reading InputReading.
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 I/O ObjectsI/O Objects Lab 12Lab 12.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Young Scholars GrantsYoung Scholars Grants Exam Next TuesdayExam Next.
March R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Today’s LabToday’s Lab SortingSorting.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class End of Chapter 2: READ Section 2.15End of Chapter 2: READ Section.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class The ProjectThe Project PointersPointers.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Class projectsClass projects Lab 13: Use the method documentation.
6/22/2015 1R. Smith - University of St Thomas - Minnesota QMCS Class Today St. Lukes Case StudySt. Lukes Case Study.
Spring R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Return HomeworkReturn Homework Class ScheduleClass Schedule Functions:
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Exam ReviewExam Review Arithmetic - I think everyone gets thisArithmetic.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Upcoming Exam – April 8Upcoming Exam – April 8 Structures ReviewStructures.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class The examThe exam Hierarchy of FunctionsHierarchy of Functions Solving.
March R. Smith - University of St Thomas - Minnesota QMCS Class Today Cryptography – introductory termsCryptography – introductory terms “Enigma”
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class RecapRecap Functions and CFunctions and C Using FunctionsUsing Functions.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230 – Today in Class Authorizing OvertimeAuthorizing Overtime Weird Java stuff: conditionals,
March R. Smith - University of St Thomas - Minnesota Today’s Class Lab 1 commentsLab 1 comments Data Types in Chapter 4Data Types in Chapter 4 Lab.
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Nested IFNested IF “Boolean” Logical Operations“Boolean” Logical.
March R. Smith - University of St Thomas - Minnesota Today’s Class First, course surveysFirst, course surveys RecapRecap More course thingsMore course.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Lab Status, Paper StatusLab Status, Paper Status Comments on Ints vs.
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 QMCS 130: Today’s Class The examThe exam –Open book, no notes, like last time Exam TopicsExam.
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 Revised Lab 14/15Revised Lab 14/15 Counting WordsCounting Words Moving.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Matlab “Matrix Laboratory”Matlab “Matrix Laboratory” Chapter 1 – matrices.
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.
March R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class Peek at Lab 16Peek at Lab 16 Side effects and arraysSide effects and.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class AssignmentsAssignments Logical operationsLogical operations Summations.
March R. Smith - University of St Thomas - Minnesota Today’s Class Homework GradedHomework Graded Hard DrivesHard Drives File StructureFile Structure.
9/21/2015 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class RecapRecap Files, writing filesFiles, writing files 1D Array Recap1D.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
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.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Grades & Lab 12Grades & Lab 12 Upcoming ExamUpcoming Exam StructuresStructures.
March /18R. Smith - University of St Thomas - Minnesota QMCS 230: Today in Class A note on methodsA note on methods ObjectsObjects Creating your.
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
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.
1/31/2016 1R. Smith - University of St Thomas - Minnesota CISC Today’s Class RecapRecap Problem 11Problem 11 Problem 12Problem 12.
2/22/2016 1R. Smith - University of St Thomas - Minnesota CISC 130: Today’s Class History Paper scheduleHistory Paper schedule RecapRecap Plus PlusPlus.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Manipulating MATLAB Vector, Matrices 1. Variables and Arrays What are variables? You name the variables (as the programmer) and assign them numerical.
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.
MATH 493 Introduction to MATLAB
Presentation transcript:

March R. Smith - University of St Thomas - Minnesota Today’s Class Class StuffClass Stuff ProjectProject Vectors and DimensionsVectors and Dimensions Import/Export of numerical matricesImport/Export of numerical matrices Working with parts of matricesWorking with parts of matrices Scripts (shell scripts)Scripts (shell scripts)

March R. Smith - University of St Thomas - Minnesota Class Stuff Exam schedulesExam schedules –How many people need to switch exam days? Potential extra credit ‘quiz’Potential extra credit ‘quiz’ –Writing functions and such

March R. Smith - University of St Thomas - Minnesota Project Project StorageProject Storage –I’ll set up shared space for each group project Project PlanProject Plan –Behavior – a paragraph on what the project does –Choices – a summary of choices the user can make –Activities – a list of things the program must do You will probably build one function per activityYou will probably build one function per activity These can be broken into more functions if you wantThese can be broken into more functions if you want –Source Files – list of source files and what activities are in each –Assignments* – which project member works on which file –Files* – description of data files (input or output) you use * = optional, appears if relevant

March R. Smith - University of St Thomas - Minnesota A Course Objective Writing functions and solving problems in both C and MatlabWriting functions and solving problems in both C and Matlab To do this, you must understand the features of each languageTo do this, you must understand the features of each language You should be able to write a simple function (with loops and conditionals) in both.You should be able to write a simple function (with loops and conditionals) in both.

March R. Smith - University of St Thomas - Minnesota Vectors in Matlab Count 1 to size, not 0 to size-1Count 1 to size, not 0 to size-1 No “declaration” – just initialize and useNo “declaration” – just initialize and use –Easy to add and remove elements, NOT like C Square Brackets for the contentsSquare Brackets for the contents –elmstreet = [ ] –No commas required –Curly braces & commas in C: int x[] = {1, 4, 2, 66, 5}; Parentheses for index valuesParentheses for index values –Like arguments to functions in Matlab or C –Square brackets in C for index values: name[i][0] –Comma separated list in Matlab: name(i, 1)

March R. Smith - University of St Thomas - Minnesota Working with vectors Addressing: first element = 1Addressing: first element = 1 –Last element: “end” Addressing some elements: foo([1 2 5])Addressing some elements: foo([1 2 5]) Adding to a vector: foo = [foo, 2, 3]Adding to a vector: foo = [foo, 2, 3] –or: foo(end+1) = 3 –Fibonacci Removing: foo(2:3) = []Removing: foo(2:3) = [] Functions on vectorsFunctions on vectors –sum, mean, max, length –find -> list of indices of non-false (non 0) elements

March R. Smith - University of St Thomas - Minnesota Boolean vectors Created with logical operatorsCreated with logical operators –x = foo > 3 –x contains 1s and 0s for elements of foo that are >3 –Can say foo(x) to create a vector of just those elements A ‘special’ kind of vectorA ‘special’ kind of vector Not just any vector of 1s and 0s.Not just any vector of 1s and 0s. Find functionFind function –Takes boolean vectors –Also takes any vector with 0s and non-0s logical functionlogical function –Converts vector of 0s and non 0s to a boolean vector

March R. Smith - University of St Thomas - Minnesota Vectors versus Function Names Both C and Matlab are stupid about thisBoth C and Matlab are stupid about this –But each in their own way What happens in C?What happens in C? –Declare a function named ‘min’ –Declare a variable named ‘min’ What happens in Matlab?What happens in Matlab? –There is a function named ‘sqrt’ –What if there is a vector named ‘sqrt’ ? –Say, sqrt = [ ] –sqrt (4) is 4!

March R. Smith - University of St Thomas - Minnesota Some Vector Exercises Sorting – [x,y] = sort(vec)Sorting – [x,y] = sort(vec) Randomness – rand(size(vec))Randomness – rand(size(vec)) Use colon to pick even valuesUse colon to pick even values IndicesIndices –Use modulus to pick even indices –Partial index lists –Negative Index lists

Assignment Write a lot of expressionsWrite a lot of expressions Answers should be expressions in terms of variables, not just numerical answers!Answers should be expressions in terms of variables, not just numerical answers! March R. Smith - University of St Thomas - Minnesota

March R. Smith - University of St Thomas - Minnesota Scripts Just save a series of Matlab commands in a fileJust save a series of Matlab commands in a file Give it a.m suffixGive it a.m suffix Refer to it by name inside Matlab as a ‘command’Refer to it by name inside Matlab as a ‘command’ Use % as comment marker (like //)Use % as comment marker (like //) Functions are different – we’ll get to that laterFunctions are different – we’ll get to that later

March R. Smith - University of St Thomas - Minnesota Import/Export of Matrices New population vectorNew population vector –Row 1 = #people in a house –Row 2-5 = four highest ages of people in a house Using Excel to type in a matrixUsing Excel to type in a matrix Using TextpadUsing Textpad Importing/ExportingImporting/Exporting –x = importdata(‘file.txt’); –x = csvread(‘file.csv’); –csvwrite(‘file2.csv’, x);

March R. Smith - University of St Thomas - Minnesota Parts of Matrices Try town(:,1), town(1,:), town(2:end,:)Try town(:,1), town(1,:), town(2:end,:)

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.