Download presentation
Presentation is loading. Please wait.
Published byBranden Gordon Modified over 9 years ago
1
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 Overview of ExamOverview of Exam
2
Shared Folders All ‘teams’ should have received e-mailsAll ‘teams’ should have received e-mails All shared folders are here:All shared folders are here: –\\Qmcs-file1\public\Smith\cisc130 \\Qmcs-file1\public\Smith\cisc130 Each project has its own shared folderEach project has its own shared folder –For example: –\\Qmcs-file1\public\Smith\cisc130\zdemo–\\Qmcs-file1\public\Smith\cisc130\zdemo\\Qmcs-file1\public\Smith\cisc130\zdemo Use ‘map network drive’ to get to it.Use ‘map network drive’ to get to it. 1/7/2016 2R. Smith - University of St Thomas - Minnesota
3
Map Network Drive Attaches a ‘drive letter’ to the folderAttaches a ‘drive letter’ to the folder –Compiler works best if the folder has a drive letter Look in the “Tools” menu of the folderLook in the “Tools” menu of the folder Click on “Map Network Drive”Click on “Map Network Drive” –Starts a wizard to set up the connection –“Reconnect on login” makes sure it’s connected when you work here. Once mapped, make a “shortcut”Once mapped, make a “shortcut” –Put it on your desktop 1/7/2016 3R. Smith - University of St Thomas - Minnesota
4
Exam Overview Focus is on defining and using functionsFocus is on defining and using functions You must know how to write functions:You must know how to write functions: –Working with summations –Working with vectors –Working with strings Also, how functions work:Also, how functions work: –What if I change this or that in a function? –What does this or that do in the function? You must know how functions are calledYou must know how functions are called –Will use ‘sequential calculation’ problem C versus Matlab Trade-Offs – when to use?C versus Matlab Trade-Offs – when to use? 1/7/2016 4R. Smith - University of St Thomas - Minnesota
5
Typical function problems How do you write a function to calculate…How do you write a function to calculate… –Given a calculation or string operation –Given some arguments –Given a type of result For C and Matlab functionsFor C and Matlab functions –Correct syntax, correct type declarations –Index from 0 for C, and from 1 for Matlab –Return the right result –Full points for the cleanest and simplest calculation Not a huge deal – maybe a point off if a solution works but is really doing it the wrong wayNot a huge deal – maybe a point off if a solution works but is really doing it the wrong way Example: using a ‘for’ loop in Matlab when you could use the ‘sum’ functionExample: using a ‘for’ loop in Matlab when you could use the ‘sum’ function 1/7/2016 5R. Smith - University of St Thomas - Minnesota
6
1/7/2016 6R. Smith - University of St Thomas - Minnesota Sequential Calculations I might have one of these, but with a vectorI might have one of these, but with a vector Will undoubtedly call functions!Will undoubtedly call functions! Calculation X Value Y Value X = 8 8? Y = 3 83 Y = X + Y - 2 89 X = Y - 3 69 Y = Y - X 63 Y = X + Y - 2 67
7
1/7/2016 7R. Smith - University of St Thomas - Minnesota Calculating with an index n ∑ i + K i=1 i=1 Given a sum with a variable maximum “n” How do we do arithmetic with the index, Like adding “K” to it?
8
1/7/2016 8R. Smith - University of St Thomas - Minnesota Other index calculations n ∑ x i i=1 i=1 Given a value for “x,” like 2 or 14, and value “n” Values x and n would be input arguments
9
1/7/2016 9R. Smith - University of St Thomas - Minnesota Sum the contents of a Vector n ∑ a i i=1 i=1 Sum of a vector named “a”, length “n” And how do we calculate the mean from this?
10
1/7/2016 10R. Smith - University of St Thomas - Minnesota Calculating with a vector n ∑ K + a i i=1 i=1 Given a vector named “a” of length “n” Apply some arithmetic, like adding “K”
11
1/7/2016 11R. Smith - University of St Thomas - Minnesota Taking Sums Apart First, is it taking elements from a vector?First, is it taking elements from a vector? –Look at the term indexing the element i, on previous slide – YES, an Indexi, on previous slide – YES, an Index –If it is subbed to another variable, you have a vector Refer to the vector in the calculationRefer to the vector in the calculation Second, are we doing arithmetic on the index?Second, are we doing arithmetic on the index? –NO, on the previous slide –If so, refer to the index variable in the calculation
12
String Operations Strings are 1 dimensional vectorsStrings are 1 dimensional vectors –Two special properties: 1. The numeric values are character codes not numbers1. The numeric values are character codes not numbers 2. In C, a string ends with a sentinel “null” value2. In C, a string ends with a sentinel “null” value Building String OperationsBuilding String Operations –Generally built with while or for loops in C or Matlab –May use “find” a lot in Matlab String ProblemsString Problems –Find specific characters in a string; return index –Replace specific characters in a string –Append one string to another –Given an index, split a string in two (part of ‘extract’ function) 1/7/2016 12R. Smith - University of St Thomas - Minnesota
13
1/7/2016 13R. Smith - University of St Thomas - Minnesota How is C different from Matlab? C is compiledC is compiled –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 Errors arise on two different occasionsErrors 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’
14
1/7/2016 14R. 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
15
1/7/2016 15R. 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
16
1/7/2016 16R. 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 (!!!)
17
1/7/2016 17R. 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
18
1/7/2016 18R. 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 http://creativecommons.org/licenses/by- sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.