Notes0302
3/29/16, 11:27 PM
Notes for 2 March
if statement and reading pdb files.
In [1]: import numpy as np
This next code segment downloads a file from the internet. It happens to be the same data as
used in Assignment 4. We'll look at how to process it
if expression
statements
end
expression
F
T
statements
if expression
statements 1
else
statements 2
end
Statements 2
F
F
expression
T
Statements 1
if exp1
statements 1
elseif exp2
statements 2
else
statements 3
end
F
F
statements 3
exp2
exp1
T
statements
Basic Concepts
Assignment, Variables, Expressions
What we are going to learn
Programming
Assignment <variablename> = <expresssion>
Variables
Naming rules & Naming guidelines
Data Types int32, uint16, single, double, char,
Expressions
More Operators
Logic
Brief Introduction to Arrays
Scalars, Vectors and Matrices
Vocabulary
Array: A collection of items that can be selected
by indices.
Matrix: A table of numbers.
A rectangular (mn) array of m rows and n
columns of elements (values).
Vector: A matrix contain
MATLAB
continued
MATLAB environment
Command Window
Workspace
Current directory
Command History
Editor Window
Figure Window
Help System
MATLAB concepts
Case Sensitive
Grouping
( ), cfw_ , [ ]
Help
> help <topic>
> doc <topic>
> helpbrowser
Quitting
Dictionaries store connections between pieces of
information. Each item in a dictionary is a keyvalue pair.
List comprehensions
squares = [x*2 for x in range(1, 11)]
Slicing a list
alien = cfw_'color': 'green', 'points': 5
finishers = ['sam', 'bob', 'ada
Jupyter/IPython Notebook Quick Start
Guide Documentation
Release 0.1
Antonino Ingargiola and other contributors
August 10, 2016
Contents
1
Contents
3
i
ii
Jupyter/IPython Notebook Quick Start Guide Documentation, Release 0.1
This document is a brief step
cfw_
"cells": [
cfw_
"cell_type": "markdown",
"metadata": cfw_,
"source": [
"# 29 August Sequences\n",
"\n",
"Today we will begin talking about sequences in python."
]
,
cfw_
"cell_type": "markdown",
"metadata": cfw_,
"source": [
"First we introduced the
cfw_
"cells": [
cfw_
"cell_type": "markdown",
"metadata": cfw_,
"source": [
"# Notes for 26 August 2016\n",
"\n",
"These are our class notes for today.\n",
"\n",
"You should be able to see them in the today.html file linked from the class
page.\n",
"\n",
Basic Concepts
Matrices and Indices
What we are going to learn
Scalars,Vectors, and Matrices
Arrays
Indices
Matrix: A rectangular
(mn) array of m
rows and n columns
of elements (values).
Vector: A matrix
containing only a
single row (1n) or
column (m1).
Basic Concepts
Matrices and Calculations
Introduction to Linear Systems
What we are going to learn
Review: Operators on scalars, vectors,
and matrices
Review: Difference between elementwise
and matrix operations
Introduction to linear systems in matrix
Name: _
COMP 116
Signed: _
Midterm
This is a PRACTICE Midterm, and NOT a dry run of the actual midterm, although some of the
questions will be similar. This has been constructed from prior offerings of the class, so credit to all
UNCCH instructors befor
Input / Output
Algorithms
Input / Output
Algorithms
Definition: An
algorithm is a
finite sequence of
instructions, a
stepbystep
procedure for
solving a problem.
Mom's Gazpacho (from epicurious)
1 egg
2 cups chopped fresh plum tomatoes
1/2 cup chopped gr
Functions
Objectives
Functions
Control flow
Syntax
Scope
Functions
Variables
Purpose
This far
Script files
All code inside one big file
maybe structured into cells
Used builtin matlab functions
sin, cos, zeros etc.
How do we structure our code?
Conditional Logic
Logical Expressions,
Selection Statements
Motivation
Step by Step Programming
All we have learned to do up to now
Execute statements in order they occur
Single path through program script
Conditional Programming
What if we only want
Program Design
Readable Programs
Whitespace
Grouping
Indentation
to show control flow
Documentation
Naming
Comments
Write programs for
people first,
computers second.
 Steve McConnell
Will you be able to
read and understand
your own code six
months
SCOPE (cont)
Main Script:

clear all
global a
a = 3;
b = 2;
c = 1;
a = callMe1( b, c );
b = callMe2( c, a );
function ret = callMe1( a, b )
ret = a1;
a = 4;
function c = callMe2( b, d )
global a
a = callMe1(b,d);
c = b;
Rotate Columns
Ponder, if you w
Basic Concepts
Least Squares and Linear Systems
What we are going to learn
Leastsquares in depth
Simple algorithms/concepts to invert
matrices
This is all implemented in MATLAB (\)
( and more sophisticated methods).
We simply revisit the principles of m
Plotting & Publishing
What we are going to learn
Plotting 2D graphics
Plot, line attributes, other properties
Formatting: Labels, titles, legends,
Multiple plots (overlaid, subplots)
Other plot commands
Publishing scripts to documents
HTML
Microsoft W
Notes0328
3/29/16, 11:32 PM
Notes for 28 March
Today we will work through the practice exam in preparation for the midterm on 30 March.
Midterm Exam 2 practice
Your exam won't be this long.
You should work on this just like it is an exam. I encourage you
Notes0115
2/8/16, 6:41 PM
Notes for 15 January 2015
Today we'll use a little Python magic to install some of our software onto your system. This is one
of the ugliest things you'll have to look at this semester. I don't expect you to understand this
code;
Markdown Cells
2/8/16, 2:58 PM
Markdown Cells
Doubleclick in this cell to see how I created it.
This is a markdown cell. Markup languages describe how to format text. HTML is a markup
language. TeX is a markup language. Markdown is a super simple markup
Notes0304
3/29/16, 11:30 PM
Notes for 4 March
Distance calculations and nested loops
In [1]: %matplotlib inline
import numpy as np
import pylab
Remember the Pythagorean theorem?
The square of the hypotenuse (the side opposite the right angle) is equal to
Notes0127
2/10/16, 1:37 PM
Notes for 27 January
Today we'll talk more about arrays and use some data to see the great things we can do with
them.
In [26]: # Boilerplate
%matplotlib inline
import numpy as np
import pylab
Note: I changed the way I'm getting
Notes0307
3/29/16, 11:31 PM
Notes for 07 March
Today we'll see more examples of functions, loops, and conditionals; all fodder for the next
exam.
In [8]: import numpy as np
np.random.seed(0)
A = np.random.random_integers(10,10,20)
A
Out[8]: array([
,
2,
Notes0203
2/10/16, 1:54 PM
Notes for 3 February
Today we will use arrays to solve simple problems.
In [1]: %matplotlib inline
import numpy as np
import pylab
But first, let's look more at np.all and np.any. Let's set up some data.
In [2]: T = np.array([0.
Notes0201
2/10/16, 1:49 PM
Notes for 1 February
Today we will try to hit everything you need for assignment 2.
Sometimes you may start to write something like:
A[0] = some expression
A[1] = some very similar expression
A[2] = another very similar expressi
Notes0226
3/29/16, 11:26 PM
Notes for 26 February
Loops and reading files.
In [1]: import numpy as np
First I will create a little list of strings.
In [2]: SL = [ 'a', 'list', 'of', 'strings' ]
SL
Out[2]: ['a', 'list', 'of', 'strings']
I can print it and
Notes0311
3/29/16, 11:31 PM
Notes for 11 March
Functions, loops, and strings
A palindrome is a string that is the same when read forward or backward often with the
extension that you can ignore spaces and nonletter characters. For example:
hannah
racecar
Notes0208
2/11/16, 8:41 PM
Notes for 8 February
Today we will begin talking about functions. You can find some useful reading on this and other
basic Python topics in this tutorial (http:/introtopython.org/introducing_functions.html).
Let's begin with con
Notes0224
3/29/16, 11:25 PM
Notes for 24 February
Strings  we've seen them before, now we'll learn how to use them for Assignment 4.
In [1]: s1 = 'This is a string'
s2 = "This is also a string"
s3 = 'So is this
one that can
span multiple lines'
s4 = "And
Notes0219
3/29/16, 11:08 PM
Notes for 19 February 2016
Helps for assignment 3
In [1]: %matplotlib inline
import numpy as np
import pylab
First a little helper function to make it easy to see my images.
In [2]: # a little helper function so I can see my re
Notes0205
2/11/16, 8:36 PM
Notes for 5 February
Today I'm going to get you to help me with an experiment. My dream is to one day teach this
class without requiring you to install the giant Anaconda package on your computers. In that
great future day you c
Notes0120
2/8/16, 6:50 PM
Notes for 20 January
Today we will begin to talk about arrays after we demonstrate how to run the assignment and
look at a couple of questions.
First a question. What is wrong with this code?
In [1]: A = 10
print("The value of A