[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Help in porting a toolbox
From: |
Mathieu Dubois |
Subject: |
Help in porting a toolbox |
Date: |
Thu, 24 May 2012 21:43:57 +0200 (CEST) |
Hello,
I'm a new Octave user (I have some experience using Matlab).
I wanted to port the SOM toolbox (see: http://www.cis.hut.fi/somtoolbox/) to
Octave.
The code is a bit old but it works under Matlab 2008a (I'm stick to this
version which is one of the reason why I want to leave Matlab).
I have some problems with code involving (s)scanf. I have read that there are a
lot of differences between Octave and Matlab in this area.
The problematic line can be found in som_read_data.m, line 225:
[s, c, e, n] = sscanf(li, '%s%[^ \t]');
The goal of the line is to read the header of a file which contains the data
label.
The variable li (the line) contains "SepalL SepalW PetalL PetalW".
Under Matlab, s contains "SepalL" (the first label) and the variable n (which
causes the error) contains 8.
Under Octave, s contains the correct value but n is 0.
This value creates an error in line 226 (because n is used to acces elements of
li).
I have used the "C" form which is closer to Matlab if I understand correctly:
[s, c, n] = sscanf(li, '%s%[^ \t]', "C");
Then n contains 1 (cause there is only 1 match).
What is the best way to emulate matlab behavior?
The code need to work on Matlab too.
Is there a way to know you're under octave (something like a ISOCTAVE
variable)? That would be a simple way to write conditionnal code like
if exists('ISOCTAVE')
% Octave specific code
else
% Matlab specific code
end
Thanks in advance,
Mathieu
- Help in porting a toolbox,
Mathieu Dubois <=
- Re: Help in porting a toolbox, Mathieu Dubois, 2012/05/24
- Message not available
- Re: Help in porting a toolbox, Jordi Gutiérrez Hermoso, 2012/05/24
- Re: Help in porting a toolbox, Mathieu Dubois, 2012/05/25
- Re: Help in porting a toolbox, Juan Pablo Carbajal, 2012/05/25
- Re: Help in porting a toolbox, Mathieu Dubois, 2012/05/28
- Re: Help in porting a toolbox, Mathieu Dubois, 2012/05/28
- Message not available
- Re: Help in porting a toolbox, Juan Pablo Carbajal, 2012/05/29