|
From: lulu <lau...@me...> - 2012-10-14 04:42:02
|
oh brother -- so now I've got to deal w/ Apple... okay thanks. here's where I am. I've downloaded matplotlib, numpy, python 2.7.3, xcode and macports to simply plot this oh-so-simple code! Which is: Curve fitting with python and pylab #import the lib from pylab import * # assuming this data set t = (0,5,10,15,20,25,30,35,40,50) V = (1,7,14,15,16,22,25,27,28,30) #show the data plot(t, v, linewidth=2.0) #assume an order N = ? #find the coefficient of the polynomial coeffs = polyfit(t,v,N) #get the polynomial output for the input best = polyval(coeffs, t) #print the coefficients print(coeffs) I have written it like this in python 2.6: import os,sys import numpy #import pylab t = (0,5,10,15,20,25,30,35,40,50) V = (1,7,14,15,16,22,25,27,28,30) #scipy.plot(t,v,linewidth=2.0) n = 4 coeffs = numpy.polyfit(t,V,n) best = numpy.polyval(coeffs,t) print coeffs print best and when I run the program, I get this: [ -1.68165168e-05 1.71262071e-03 -6.39152514e-02 1.59163337e+00 1.04578755e+00] [ 1.04578755 7.60964036 12.11505162 15.46811522 18.32267732 21.08033633 23.89044289 26.6500999 29.0041625 29.81368631] when I run in 2.7.3 it looks like this: import os,sys import numpy as np import pylab t = (0,5,10,15,20,25,30,35,40,50) V = (1,7,14,15,16,22,25,27,28,30) #scipy.plot(t,v,linewidth=2.0) n = 4 coeffs = numpy.polyfit(t,V,n) best = numpy.polyval(coeffs,t) print coeffs print best And my error msg is this: ImportError: No module named numpy any ideas? What I'm looking for is a visual. -- View this message in context: http://matplotlib.1069221.n5.nabble.com/installating-matplotlib-in-mac-10-7-4-for-python-2-6-tp39436p39448.html Sent from the matplotlib - users mailing list archive at Nabble.com. |