In article <fa433710-0953-4b4a-96f6-2f7d1b9af...@googlegroups.com>, Maura E Monville <maura.monvi...@gmail.com> wrote:
> My supervisor has palmed me off with a python code, written by a > collaborator, which implements an algorithm aimed at denoising the dose > distribution (energy per unit mass) output from a radiation transport Monte > Carlo code. > My task is to translate the python code into a MatLab code. Interestingly, I was recently given the task of translating a Matlab program into Python. Just the opposite of your problem. And I knew neither! > A colleague of mine and I stared at the python code for a while without > understanding the logic. > To me that code looks like Chinese or Arabian. > I don't have clear ideas about the syntax and python variables. For instance, > in MatLab there is the cell array storage type to host data of different > type. I have no idea how a 3D matrix can be loaded through python. Does the Python program use scipy and numpy modules? Those, in my short experience, provide the closest equivalent to Matlab matrices and functions. They allowed me to do almost a line-by-line translation of Matlab code into Python. The h5py module allows you to read and write Matlab "save" files in Python, too. Some of the differences between Matlab and Python: 1. Matlab array indexing starts at 1; Python starts at 0. 2. Matlab uses parentheses () for sequence indexing; Python uses brackets []. 3. Matlab arrays are column-major order; Numpy arrays are row-major order, Post Python code here or provide a link to code posted elsewhere for additional help. Good luck. -- Jim Gibson -- https://mail.python.org/mailman/listinfo/python-list