e in octave

Ben Abbott bpabbott at mac.com
Sun Nov 9 17:31:56 CST 2008


On Nov 7, 2008, at 7:15 PM, james mcskimming wrote:

> i've always accepted that e=exp(1) is a constant available in Octave
> just like pi and others.  But i wrote code using e as a constant  
> only to
> discover it didn't work when a friend tried to run it on Matlab.
> I've never used Matlab but assumed there would be compatability at  
> such
> a basic level.
> Is there a reason why? and other than defining the variable e=exp(1)  
> in
> code for Matlab, is there a better way?
> thx
> Jas

I'm confused. Are you asking why Octave handles "e" as it does "pi" or  
why Matlab does not?

Regarding a better way, I'd create a function in Matlab and place it  
in the path.

----------- save as "e.m" -----------
function a = e ()
   a = exp(1);
end
------------------------------------------

That way "e" will be available to all your scripts and functions.

Ben



More information about the Help-octave mailing list