lec7_review

# lec7_review - from pylab import * #-EXC...

This preview shows pages 1–2. Sign up to view the full content.

from pylab import * #-------EXC 1--------- x=linspace(0,10,50) y=(x-2)**2*sin(x) #Setup to 2D array and take a transpose so it will write to file in columns # (this step isn't REALLY necessary, but makes it easier to look at the data in the file). XY=array([x,y]).transpose() np.savetxt('mydata.txt',XY,delimiter='\t') #load it back in again just as an exercise newx,newy=np.loadtxt('mydata.txt',unpack=True) #Make the plot a decorate it plot(newx,newy,'g-s',ms=6) grid() ymax=y.max() xmax=x[y.argmax()] text(2,20,'Maximum is at \n (%2.2f,%2.2f)'%(xmax,ymax),fontsize=16) arrow(xmax,ymax,-3,-10,lw=3) #-------SLIDE 2 --------- #print '-'*20,'a is an list', '-'*20 #def funct(a): # for i in range(len(a)): # a[i]=a[i]**2 # print 'Inside function: a=', a # return #a=[1,2,3,4] #print 'Outside function: a=', a #funct(a) #print 'Outside function: a=', a # #print '-'*20,'a is an array', '-'*20 #def funct(a): # a[0]=2 # print 'Inside function: a=', a # return #a=array([1,2,3,4]) #print 'Outside function: a=', a

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## lec7_review - from pylab import * #-EXC...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online