Please tell me if this code works

Ben Abbott bpabbott at mac.com
Sun Feb 10 12:04:42 CST 2008


On Feb 10, 2008, at 12:39 PM, lc wrote:

> Maybe I have a too old version of octave, but, please,
> can you tell me if this code works:
>
> function V= vol(h,s); V=h*s.R^2; endfunction
> a.R=10
>
> a.v=@(h)( vol(h, a ) );
> a.v(2)
>
> I got the error
> error: `a' undefined near line ...
>
> Thanks
> lc

This is what I got.

octave:1> function V= vol(h,s); V=h*s.R^2; endfunction
octave:2> a.R=10
a =
{
   R =  10
}

octave:3>
octave:3> a.v=@(h)( vol(h, a ) );
octave:4> a.v(2)
ans =  200

octave:5> ver
----------------------------------------------------------------------
GNU Octave Version 3.0.0+
GNU Octave License: GNU General Public License
Operating System: Darwin 9.1.0 Darwin Kernel Version 9.1.0: Wed Oct 31  
17:46:22 PDT 2007; root:xnu-1228.0.2~1/RELEASE_I386 i386
----------------------------------------------------------------------

Ben


More information about the Help-octave mailing list