|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
error in a Matlab toolbox. Problem with" cellfun".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. Thanks in advance cheers _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: error in a Matlab toolbox. Problem with" cellfun".On Tue, Nov 3, 2009 at 11:45 AM, Philipp Leser <pleser@...> 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 _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
|
Re: error in a Matlab toolbox. Problem with" cellfun".Philipp Leser 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. > > Thanks in advance > > cheers > > ------------------------------------------------------------------------ > > _______________________________________________ > Help-octave mailing list > Help-octave@... > https://www-old.cae.wisc.edu/mailman/listinfo/help-octave > Try replacing the & in the if-condition with &&, and | with ||. The && and || operators short-circuit, the & and | operators do not. Seems like that condition was written with short-circuit boolean logic in mind (rather than bitwise logic). hth David _______________________________________________ Help-octave mailing list Help-octave@... https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
| Free embeddable forum powered by Nabble | Forum Help |