help-octave
[Top][All Lists]

Re: Distinguishing Octave from Matlab

 From: Ben Abbott Subject: Re: Distinguishing Octave from Matlab Date: Fri, 15 Feb 2008 23:33:59 -0500

 On Feb 15, 2008, at 12:31 PM, Ben Abbott wrote:On Feb 15, 2008, at 12:04 PM, David Bateman wrote:Ben Abbott wrote:On Feb 15, 2008, at 11:31 AM, David Bateman wrote:Ben Abbott wrote:On Feb 15, 2008, at 5:02 AM, David Bateman wrote:Use Octave 3.0.0 and use the matlab syntax everywhere, in mostcases itshould then just work.. If there are any other differences thatpreventit working then they should be reported as bugs. A function that  doeswhat you want isfunction ret = isoctave ()persistent isoctif (isempty (isoct))  isoct = exist('OCTAVE_VERSION') ~= 0;endret = isoct;endRegardsDavidMight this be added to the core functions?BenHow does that help you if we can't convince mathworks to do the  same?D.Good point Perhaps an octave version of an existing Matlab function ("ver","version", "verLessThan", ?) could do the job?Under matlab R2007b I seea = ver('matlab')a =      Name: 'MATLAB'   Version: '7.5'   Release: '(R2007b)'      Date: '02-Aug-2007'a = ver('octave')a =0x0 struct array with fields:   Name   Version   Release   DateThe octave "ver" function doesn't take an argument. To get thefunctionality you want this way you could modify Octave's ver so  that itassumes the argument is 'octave' if it is missing and then something  likeif (strcmpi (pack, "octave")) ## Do what is already done, plus set ret if neededelse lst = pkg("list"); ret = []; for i = 1 : length (lst)    if (strcmpi (pack, lst{i}.name))      ret = struct ("Name", lst{i}.name, "Version", lst{i}.version,"Release", [], "Date", lst{i}.date);      break;    endif endfor if (isempty (ret))    ## How do you create an empty structure?    ret = struct ("Name", [], "Version", [], "Release", [], "Date",  []);    ret(1) = [];  endifendifwould get the type of behavior you want as long as someone doesn'tcreate an "octave" toolbox in matlab or a "matlab" package in octave.D.That's a good start.I'm busy for the next several hours, but will look more closely at how  Matlab's version works and take a shot at this later today.BenOk, I've attached a diff respecting mercurial version, as well as the complete m-file.Distinguishing between Matlab and Octave may be done as, v = ver; if (strcmpi(v(1).Name,'matlab')   % Matlab code here elseif (strcmpi(v(1).Name,'octave')   % Octave code here endBen ver.diff
Description: Binary data ver.m
Description: Binary data

reply via email to