1/7/2016 1r. smith - university of st thomas - minnesota today’s class mostly lab timemostly lab...

18
08/15/22 1 R. Smith - University of St Thomas - Minnesota Today’s Class Today’s Class Mostly Lab Time Mostly Lab Time How to use shared folders How to use shared folders Overview of Exam Overview of Exam

Upload: branden-gordon

Post on 19-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 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

04/21/23 1R. Smith - University of St Thomas - Minnesota

Today’s ClassToday’s Class

• Mostly Lab TimeMostly Lab Time• How to use shared foldersHow to use shared folders• Overview of ExamOverview of Exam

Page 2: 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

Shared FoldersShared 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

• Each project has its own shared folderEach project has its own shared folder– For example:For example:

– \\Qmcs-file1\public\Smith\cisc130\zdemo

• Use Use ‘map network drive’ ‘map network drive’ to get to it.to get to it.

04/21/23 2R. Smith - University of St Thomas - Minnesota

Page 3: 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

Map Network DriveMap Network Drive

• Attaches a ‘drive letter’ to the folderAttaches a ‘drive letter’ to the folder– Compiler works best if the folder has a drive letterCompiler 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 connectionStarts a wizard to set up the connection– ““Reconnect on login” makes sure it’s connected when you Reconnect on login” makes sure it’s connected when you

work here.work here.

• Once mapped, make a “shortcut”Once mapped, make a “shortcut”– Put it on your desktopPut it on your desktop

04/21/23 3R. Smith - University of St Thomas - Minnesota

Page 4: 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

Exam OverviewExam 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 summationsWorking with summations– Working with vectorsWorking with vectors– Working with stringsWorking with strings

• Also, how functions work:Also, how functions work:– What if I change this or that in a function?What if I change this or that in a function?– What does this or that do in the 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’ problemWill use ‘sequential calculation’ problem

• C versus Matlab Trade-Offs – when to use?C versus Matlab Trade-Offs – when to use?

04/21/23 4R. Smith - University of St Thomas - Minnesota

Page 5: 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

Typical function problemsTypical function problems

• How do you write a function to calculate…How do you write a function to calculate…– Given a calculation or string operationGiven a calculation or string operation– Given some argumentsGiven some arguments– Given a type of resultGiven a type of result

• For C and Matlab functionsFor C and Matlab functions– Correct syntax, correct type declarationsCorrect syntax, correct type declarations– Index from 0 for C, and from 1 for MatlabIndex from 0 for C, and from 1 for Matlab– Return the right resultReturn the right result– Full points for the cleanest and simplest calculationFull points for the cleanest and simplest calculation

• Not a huge deal – maybe a point off if a solution works but Not a huge deal – maybe a point off if a solution works but is really doing it the wrong wayis really doing it the wrong way

• Example: using a ‘for’ loop in Matlab when you could use Example: using a ‘for’ loop in Matlab when you could use the ‘sum’ functionthe ‘sum’ function

04/21/23 5R. Smith - University of St Thomas - Minnesota

Page 6: 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

04/21/23 6R. Smith - University of St Thomas - Minnesota

Sequential CalculationsSequential 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!

CalculationCalculation X ValueX Value Y ValueY Value

X = 8X = 8 88 ??

Y = 3Y = 3 88 33

Y = X + Y - 2Y = X + Y - 2 88 99

X = Y - 3X = Y - 3 66 99

Y = Y - XY = Y - X 66 33

Y = X + Y - 2Y = X + Y - 2 66 77

Page 7: 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

04/21/23 7R. Smith - University of St Thomas - Minnesota

Calculating with an indexCalculating with an index

nn

∑∑ i + Ki + K i=1i=1

Given a sum with a variable maximum “n”Given a sum with a variable maximum “n”

How do we do arithmetic with the index,How do we do arithmetic with the index,

Like adding “K” to it?Like adding “K” to it?

Page 8: 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

04/21/23 8R. Smith - University of St Thomas - Minnesota

Other index calculationsOther index calculations

nn

∑∑ xxii

i=1i=1

Given a value for “x,” like 2 or 14, and value “n”Given a value for “x,” like 2 or 14, and value “n”Values x and n would be input argumentsValues x and n would be input arguments

Page 9: 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

04/21/23 9R. Smith - University of St Thomas - Minnesota

Sum the contents of a VectorSum the contents of a Vector

nn

∑∑ aai i i=1i=1

Sum of a vector named “a”, length “n”Sum of a vector named “a”, length “n”And how do we calculate the mean from this?And how do we calculate the mean from this?

Page 10: 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

04/21/23 10R. Smith - University of St Thomas - Minnesota

Calculating with a vectorCalculating with a vector

nn

∑∑ K + aK + ai i i=1i=1

Given a vector named “a” of length “n”Given a vector named “a” of length “n”Apply some arithmetic, like adding “K”Apply some arithmetic, like adding “K”

Page 11: 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

04/21/23 11R. Smith - University of St Thomas - Minnesota

Taking Sums ApartTaking 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 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, If it is subbed to another variable, you have a vectoryou 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 slideNO, on the previous slide– If so, refer to the If so, refer to the index variableindex variable in the calculation in the calculation

Page 12: 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

String OperationsString Operations

• Strings are 1 dimensional vectorsStrings are 1 dimensional vectors– Two special properties:Two special properties:

• 1. The numeric values are 1. The numeric values are character codescharacter codes not numbers 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 MatlabGenerally built with while or for loops in C or Matlab– May use “find” a lot in MatlabMay use “find” a lot in Matlab

• String ProblemsString Problems– Find specific characters in a string; return indexFind specific characters in a string; return index– Replace specific characters in a stringReplace specific characters in a string– Append one string to anotherAppend one string to another– Given an index, split a string in two (part of ‘extract’ function)Given an index, split a string in two (part of ‘extract’ function)

04/21/23 12R. Smith - University of St Thomas - Minnesota

Page 13: 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

04/21/23 13R. Smith - University of St Thomas - Minnesota

How is C different from Matlab?How is C different from Matlab?

• C is C is compiledcompiled– A special program, the A special program, the compilercompiler, converts the C program from , converts the C program from

ASCII source code into binary coded computer instructionsASCII source code into binary coded computer instructions– In Matlab, the computer has to do that conversion whenever In Matlab, the computer has to do that conversion whenever

we type in an expression – we say Matlab is we type in an expression – we say Matlab is interpretedinterpreted

• Errors arise on two different occasionsErrors arise on two different occasions– Syntax errors and some usage errors are found in compilationSyntax 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’Other errors arise when the program actually ‘runs’

Page 14: 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

04/21/23 14R. Smith - University of St Thomas - Minnesota

Why is C popular?Why is C popular?

• It is portableIt is portable– Easy to modify to create programs for another computerEasy to modify to create programs for another computer– The compiler itself is easily ‘hosted’ on other computersThe 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 themA rich set of data types and operations on them– Standard control structures, allows structured programmingStandard control structures, allows structured programming– Only missing object technologyOnly missing object technology

• ““Close to the machine”Close to the machine”– Easy to write highly technical programs for operating systemsEasy to write highly technical programs for operating systems– Mechanisms map easily to the machine level = efficientMechanisms map easily to the machine level = efficient

• Highly efficient – optimizing compilersHighly efficient – optimizing compilers

Page 15: 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

04/21/23 15R. Smith - University of St Thomas - Minnesota

Problems with CProblems with C

• C programs can be hard to readC programs can be hard to read– Obfuscated C ContestObfuscated C Contest

• Data types are not enforcedData types are not enforced– Compiler doesn’t catch every error it couldCompiler 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 answerExpressions don’t evaluate consistently to the same answer– In this class, we note and avoid operations with side effectsIn this class, we note and avoid operations with side effects

• Compared to MatlabCompared to Matlab– Requires more steps, more typing to yield a simple resultRequires more steps, more typing to yield a simple result– Unsophisticated output: no graphingUnsophisticated output: no graphing– Rigid handling of input text – programmer must write code to Rigid handling of input text – programmer must write code to

interpret and process typed inputsinterpret and process typed inputs

Page 16: 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

04/21/23 16R. Smith - University of St Thomas - Minnesota

Who uses C today?Who uses C today?

• Operating systemsOperating systems– Windows is mostly written in CWindows is mostly written in C– Linux/Unix is mostly written in C – that’s where C startedLinux/Unix is mostly written in C – that’s where C started– Macintosh software is mostly written in CMacintosh software is mostly written in C– C++ is an object-oriented version that sees lots of useC++ is an object-oriented version that sees lots of use

• CompilersCompilers– C and C++ compilers are written in CC and C++ compilers are written in C

• Application packages, like ExcelApplication packages, like Excel– Many are being written in Java these days – GUIs are easierMany are being written in Java these days – GUIs are easier

• Embedded ApplicationsEmbedded Applications– Gas pumps, USB hubs, cell phones, lab equipment (!!!)Gas pumps, USB hubs, cell phones, lab equipment (!!!)

Page 17: 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

04/21/23 17R. Smith - University of St Thomas - Minnesota

Choosing between C and MatlabChoosing between C and Matlab

• Matlab is Better for…Matlab is Better for…

• Vector and matrix mathVector and matrix math– When sizes aren’t known When sizes aren’t known

ahead of timeahead of time

• Graphing – it’s built inGraphing – it’s built in• Processing standard file Processing standard file

formats – built informats – built in– Images and spreadsheetsImages and spreadsheets

• C is Better for…C is Better for…

• Group programmingGroup programming– Established ways of sharing Established ways of sharing

the workthe work

• Tight quartersTight quarters– When the computer is too When the computer is too

small to run Matlabsmall to run Matlab

• Little or no OS supportLittle or no OS support– Computer doesn’t have Computer doesn’t have

graphics, not very interactivegraphics, not very interactive

• Access to I/O hardwareAccess to I/O hardware– Easy to manipulate I/O control Easy to manipulate I/O control

registers from Cregisters from C

Page 18: 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

04/21/23 18R. Smith - University of St Thomas - Minnesota

Creative Commons LicenseCreative Commons License

This work is licensed under the Creative This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United Commons Attribution-Share Alike 3.0 United

States License. To view a copy of this license, States License. To view a copy of this license, visit http://creativecommons.org/licenses/by-visit http://creativecommons.org/licenses/by-

sa/3.0/us/ or send a letter to Creative sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Commons, 171 Second Street, Suite 300, San

Francisco, California, 94105, USA.Francisco, California, 94105, USA.