|
From: | Ernst Reissner |
Subject: | octave and oo |
Date: | Sat, 13 Nov 2010 11:54:47 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.15) Gecko/20101026 SUSE/3.0.10 Thunderbird/3.0.10 |
Hi all, at the moment i work through a tutorial with oo in Matlab http://www.mathworks.com/help/techdoc/matlab_oop/f3-28024.html and octave and try to reproduce the example there: It is about defining a class DocPolynom of polynomials. The constructor seems to work well, function obj = DocPolynom(c) % Construct a DocPolynom object using the coefficients supplied if isa(c,'DocPolynom') obj.coef = c.coef; else obj.coef = c(:).'; end end but although it is do easy, the double-method does not: function c = double(obj) % DocPolynom/Double Converter c = obj.coef; end What i obtain is p = DocPolynom([1 0 -2 -5]) p = { coef = 1 0 -2 -5 } octave:16> c = double(p) error: struct type invalid as index value I am sure that my m-files are evaluated like char.m defined below, because it produces failures: octave:16> p = DocPolynom([1 0 -2 -5]); octave:17> char(p) error: scalar cannot be indexed with . error: called from: error: /home/ernst/Software/resource/octave/m/@DocPolynom/double.m at line 3, column 3 error: evaluating argument list element number 1 error: evaluating argument list element number 1 error: evaluating argument list element number 1 error: evaluating argument list element number 1 error: /usr/share/octave/3.2.4/m/general/int2str.m at line 105, column 5 error: evaluating argument list element number 1 error: evaluating argument list element number 1 error: /usr/share/octave/3.2.4/m/general/int2str.m at line 69, column 11 error: evaluating argument list element number 1 error: /home/ernst/Software/resource/octave/m/@DocPolynom/char.m at line 36, column 23 what is wrong here?? Greetings, Ernst |
[Prev in Thread] | Current Thread | [Next in Thread] |