[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: error in a Matlab toolbox. Problem with" cellfun".
From: |
Jaroslav Hajek |
Subject: |
Re: error in a Matlab toolbox. Problem with" cellfun". |
Date: |
Tue, 3 Nov 2009 15:18:16 +0100 |
On Tue, Nov 3, 2009 at 11:45 AM, Philipp Leser <address@hidden> wrote:
> Hey,
>
> I try to play around with the Matlog
> (http://www.ise.ncsu.edu/kay/matlog/)toolbox and run it on Octave. It’s
> quite interesting since I can run Matlog on MATLAB at the university and
> compare it to Octave. On Matlab the Matlog toolbox runs quite smooth, but on
> Octave I get some error messages. To me it is an educating experience on the
> few incompatibilities of the two tools.
>
>
>
> Here is one error I really have trouble understanding. Would be happy about
> any hints or help.
>
>
>
> I run the function “vrpsavings”. The function itself calls a function
> called LocTC in an “try and catch” construction:
>
>
>
>
>
> “try % Use for error checking and to store input arguments
>
> locTC([],C,cap,twin,locfeas);
>
> catch
>
> errstr = lasterr;
>
> idx = find(double(errstr) == 10);
>
> error(errstr(idx(1)+1:end))
>
> end “;
>
>
>
> where C is a NxN matrix, cap a cell object and twin locfeas are a []
> double.
>
>
>
>
>
> In the line “ locTC([],C,cap,twin,locfeas)” I get the error message.
>
>
>
> “error: cellfun: second argument must be a cell array
>
> error: evaluating argument list element number 1
>
> error: evaluating argument list element number 1
>
> error: called from:
>
> error: C:\Octave\3.2.2_gcc-4.3.0\bin\matlog\locTC.m at line 180, column 1
>
> error: C:\Octave\3.2.2_gcc-4.3.0\bin\matlog\vrpsavings_test.m at line 54,
> column 1
>
> “
>
>
>
> In “locTC” line 180 to 186
>
>
>
>
>
>
>
> “
>
> if isfirstcall & ~isempty(loc) & (~(isreal(loc) | iscell(loc)) | ...
>
> (~iscell(loc) & (min(size(loc)) ~= 1 | ...
>
> any(loc(:) < 1 | loc(:) > n))) | ...
>
> (iscell(loc) & (any(cellfun('prodofsize',loc) ~= ...
>
> cellfun('length',loc)) | any([loc{:}] < 1 | [loc{:}] > n))))
>
> error('"loc" not a valid loc seq.')
>
> end
>
> “
>
>
>
>
>
> When I run the “vrpsavings” file in the Matlab debugger, the
> “locTC([],C,cap,twin,locfeas)” returns “inf”, but no error.
>
> Why? I don’t get it.
>
>
In Matlab & and | operators use short-circuit evaluation if used in
if-clause conditions (but not otherwise). This is a design flaw in
Matlab that Octave intentionally does not reproduce. && and || should
be used instead (these work in Matlab as well).
see http://www.gnu.org/software/octave/FAQ.html#MATLAB-compatibility
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz