0

I work both in Matlab and GNU Octave.

A problem i have common is that Octave have a slightly different method for creating functions as MatLab have…

Example Matlab:

function [Y1, … , YN] myfunc (x1, …,xm)
    Some things to do
end

and octave do tha same function this way

function [Y1, … , YN] myfunc (x1, …,xm)
    Some things to do
endfunction

Not a big difference but enough that matlab functions won't run at Octave and probably also other way around.

Is there a work around that a scrips starts reading of it is working in matlab or octave and then choose what function it needs?

if matlab == true
then
[]=myfunc()
elseif octave == true
[] =myfuncoct()
else
error(…)
end

Thanks hope for some help

Jan-Bert
  • 921
  • 4
  • 13
  • 22
  • 1
    Check [this](http://stackoverflow.com/questions/2246579/how-do-i-detect-if-im-running-matlab-or-octave) link – Benoit_11 Apr 23 '15 at 15:26
  • Thanks missed that one… – Jan-Bert Apr 23 '15 at 15:29
  • In Octave 3.8.2 you can use either `function` ... `end` or `function` ... `endfunction`. If your need for compatibility is greater than the slight advantage of easier trouble shooting then just use the matlab version. You can sometimes get lost in a sea of stacked `end`s at the end of a lot of nested indents, so octave's `endfunction` is a tiny bit easier to debug. –  May 01 '15 at 09:07

0 Answers0