简体   繁体   中英

why function showing not defined in enthought canopy?

I am a new user in Enthought Canopy Python.

** At first I tried to run the code, it gave error message eg

MatrixCreate is not defined.

** Then I tried importing the file by typing command: eg

import file.py ; it gave error "no module named file.py"

** Then I tried:

import MatrixCreate(1, 50);

gave me error message invalid syntax with arrow directing before braces.

** Then I tried importing the function from matplot: eg

from matplotlib import matrixcreate;

it gave error message

cannot import matrixcreate

** further I tried:

matrixcreate.show(); 

gave me error

name 'matixcreate' is not defined

Please guide how I can run my code.

MatrixCreate does not appear to be a part of any module that you could import. Most probably you are using some incomplete code that is missing a function called MatrixCreate . However, to create an empty matrix of the size [1, 50] use:

import numpy
matrix = numpy.zeros(shape=(1,50))
print matrix

you can further make a function that creates a matrix for you:

import numpy
def MatrixCreate(a,b):
   matrix = numpy.zeros(shape=(a,b))
   return matrix
print MatrixCreate(1,50)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM