2012/10/18 Joanna Rutkowska <address@hidden
<mailto:address@hidden>>
Hello, I've created a simple class:
function m = motor (name, Kv, Rm, I0)
m.name <http://m.name> = name;
m.Kv = Kv;
m.Rm = Rm;
m.I0 = I0;
m = class (m, "motor");
end
...and one simple method:
function power = power_out (motor, u, i)
power = (u - i*motor.Rm) * (i - motor.I0);
end
... and I created an object of the class motor:
octave:1> m1 = motor ("Sample motor", 400, 0.05, 1);
... but I cannot call the power_out method using the traditional "OO
way":
octave:2> m1.power_out (1,1);
error: invalid index for class
... only this form seems to work:
octave:2> power_out (m1, 1, 1);
Is it how this is supposed to be in Octave? The object.method()
calling convention is much more intuitive and more readable than
method(object) IMHO. Also, it clearly allows to avoid name conflicts
if I got some global function or another method with the same
name...
Thanks,
joanna.
_________________________________________________
Help-octave mailing list
address@hidden <mailto:address@hidden>
https://mailman.cae.wisc.edu/__listinfo/help-octave
<https://mailman.cae.wisc.edu/listinfo/help-octave>
Hi,
according to
http://www.gnu.org/software/octave/doc/interpreter/Creating-a-Class.html#Creating-a-Class,
all class definitions must be inside folders starting with an @ symbol.
Did you do that?