0

I have a .p file (for the example named EX1.p) that contains a MATLAB function that I need in my python code and I tried to import the file/the function but with no success. Hope someone can help

EigenMan
  • 3
  • 3
  • Why do you assume that importing file with function written in *different* programming lanaguage should just work? – Daweo Oct 17 '21 at 12:20
  • Because is it part of an exercise in one of my courses (-_-') – EigenMan Oct 17 '21 at 13:16
  • Maybe ask your instructor for more guidance. P-files are encrypted and can only be run by MATLAB, they cannot be edited. Maybe you are supposed to call MATLAB from within Python? Or maybe you are not supposed to use Python at all? – Cris Luengo Oct 17 '21 at 13:20

1 Answers1

0

I think there is at least two options: oct2py (only valid if your code may be run in Octave) and Matlab Engine. You can find an explanation of both options here.

PedroRodriguez
  • 368
  • 2
  • 9
  • 1
    P-files don't run in Octave though. They're an encoded version of an M-file, intended to hide the code from the users. – Cris Luengo Oct 21 '21 at 15:25
  • That's true, it's encrypted code. Therefore, the only option is the Matlab engine, explained by Mathworks here (https://es.mathworks.com/help/matlab/matlab-engine-for-python.html) – PedroRodriguez Oct 21 '21 at 16:20