Skip to main content

A note on converting API code between Python, Matlab, and Mathematica


Forum|alt.badge.img+1

Just a quick note on converting API code between Mathematica, Python, and Matlab.  API code will be nearly identical in all languages, so it’s fairly easy to convert code from one to the other.  Here’s an example of getting the surface type from the LDE.

Mathematica:
mySurface = primarySystem@LDE@GetSurfaceAt[2]@Type@ToString[“”]

Python or Matlab:

mySurface = primarySystem.LDE.GetSurfaceAt(2).Type.ToString()

And a table of the differences:

Mathematica reserves the “_” character for variables, so an upper-case U is used instead.  For example, in Mathematica, a new FFT MTF analysis can be launched this way:
newWin = primarySystem@Analyses@NewUFftMtf[]

But in Matlab or Python, this is:

newWin = primarySystem.Analyses.New_FftMtf()

Did this topic help you find an answer to your question?

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings