MATLAB to Python Conversion, matrices and lists -
how translate following python matlab? i'm still trying wrap head around lists/matrices , arrays in numpy, etc.
outframe(:,[4:4:nout-1]) = 0.25*inframe(:,[1:n-1]) + 0.75*inframe(:,[2:n]) pos=(beamnum>0)*(beamnum<=nbeams)*(binnum>0)*(binnum<=nbins)*((beamnum-1)*nbins+binnum) index =1:512: outarray(index,:) =uint8(interp1([1:n],inarray64(index,:),[1:.25:n],method)) (there's other stuff, these particular statements i'm not sure how make sense of. have numpy imported,
the main workhorse in numpy ndarray (or array). part replace matlab matrices when translate code. matlab matrix, ndarray stores homogeneous data (ie float64) , optimized numerical operations.
the numpy matrix subclass of ndarray can convenient linear algebra intensive applications. here more info differences between two.
the python list more matlab cell array (though not same). it's 1 of basic python data structures, in scientific applications find comes when need hold heterogeneous data. (or when you're doing simple , don't want go trouble of creating numpy array).
your code above can converted verbatim python using ndarray , replacing () [] indexing , taking account indexing starts @ 1 in matlab , 0 in python i.e. : first element in matlab element 1, , in python element 0.
Comments
Post a Comment