Skip to content Skip to sidebar Skip to footer

Converting/ Translate From Python To Octave Or Matlab

I have a Python-Code and want to rewrite it in Octave, but I meet so many problems during the converting. I found a solution for some of them and some of them still need your help.

Solution 1:

return np.r_[x,xoie,xooe,x[0]], np.r_[y,yoie,yooe,y[0]]

The function returns 2 values, both arrays created by np.r_.

np.r_[....] has indexing syntax, and ends up being translated into a function call to the np.r_ object. The result is just the concatenation of the arguments:

In [355]: np.r_[1, 3, 6:8, np.array([3,2,1])]
Out[355]: array([1, 3, 6, 7, 3, 2, 1])

With the [] notation it can accept slice like objects (6:8) though I don't see any of those here. I'd have to study the rest of the code to identify whether the other arguments are scalars (single values) or arrays.

My Octave is rusty (though I could experiment with the conversion).

t = np.lispace... # I think that exists in Octave, a 1000 values
x = x0+r*np.cos(t)  # a derived array of 1000 values

xoie one of the values returned by coords_inv; may be scalar or array. x[0] the first value of x. So the r_ probably produces a 1d array made up of x, and the subsequent values.


Post a Comment for "Converting/ Translate From Python To Octave Or Matlab"