Learning Python -Beginner Question

  • Python
  • Thread starter poobar
  • Start date
  • #1
21
0

Main Question or Discussion Point

Learning Python --Beginner Question

Hey All,
I am translating a whole lot of code from MATLAB to Python/NumPy/SciPy. However, I am having a lot of trouble creating column vectors. I know that in MATLAB it would go like this:

a = [1,2,3,4,5,6,78], colvec = a'

if anyone know the answer of has any good hints, please answer!

thanks!
 

Answers and Replies

  • #2
418
3


numpy.transpose(...)
 
  • #3
21
0


okay. good. that works, so thank you very much.

naturally, a new problem has presented itself. i think this one is somewhat more complicated.

i have an image.tif that i am trying to open as a matrix in python. i learned about the Image.open(...) but i get an error when i try to do this.

i typed in:

from Image import Image
im = Image.open('C:\.....tif')

I get back:

AttributeError
C:\Users\student\Desktop\(<python console> in <module>()
AttributeError: class Image has no attribute 'open'


help?

thanks
 
  • #4
418
3
  • #5
673
2


numpy.transpose(...)
you can also use a.T
Also, you may want to keep a copy of Numpy for Matlab user handy.

I'm not sure tif images are supported by PIL.
According to the documentation, http://www.pythonware.com/library/pil/handbook/format-tiff.htm [Broken] is supported.
Are you sure that you've instantiated the object correctly and given the correct object path?

Also, I think your import statements might be wonky, and that could be throwing off your references. Try
Import Image
Image.open
and
from PIL import Image
Image.open
 
Last edited by a moderator:

Related Threads on Learning Python -Beginner Question

  • Last Post
Replies
4
Views
3K
Replies
31
Views
6K
  • Last Post
Replies
14
Views
5K
  • Last Post
Replies
18
Views
1K
  • Last Post
Replies
14
Views
3K
Replies
12
Views
1K
Replies
4
Views
991
Replies
10
Views
914
Replies
9
Views
955
Replies
4
Views
971
Top