Use matlab-physical-units toolbox in octave

There is a nice matlab-toolbox providing a class that adds physical units to a number: physical-units-for-matlab
Calculations yield a value and the resulting unit. I guess this toolbox also meets this request.

Problem description

  • cloned the repository from github
  • the toolbox works fine with Matlab. I don’t want to use Matlab.
  • using the toolbox with octave doesn’t work and I do not understand why:

octave:3> rotationSpeed = 2500 * u.rpm
error: max_recursion_depth exceeded
error: called from
baseUnitSystem

octave:4>

  • coding of the physical-units-for-matlab-toolbox might be an issue:
    I had change the coding by copying the code from the website, before that I got

warning: Invalid UTF-8 byte sequences have been replaced.
error: max_recursion_depth exceeded
error: called from
baseUnitSystem

What do I have to do to use this toolbox with octave? As far as I can see the core functionality is in the files u.m and baseUnitSystem.m, but I cannot spot what is causing the problem. Could anybody give me a hint, please?

I understood that code from Mathworks FileExchange must not be used with octave, but this toolbox is published on github under the BSD 2-clause license, so I guess it is not a legal issue using it with octave.

My system

  • Ubuntu 20.04
  • GNU Octave, version 7.1.0
  • Installation method: ubuntu software

I’m not familiar with the toolbox, but have you tried opening the file in the editor and stepping through the code to see where the problem actually occurs? might help us offer suggestions on workarounds.