string - MATLAB vs. GNU Octave Textscan disparity -
i wish read data .dat file without saving file first. in order so, code looks follows:
urlsearch= 'http://minorplanetcenter.net/db_search/show_object?utf8=&object_id=2005+pm'; url= 'http://minorplanetcenter.net/tmp/2005_pm.dat'; urlmidstep=urlread(urlsearch); urldata=urlread(url); received= textscan(urldata , '%5s %7s %1s %1s %1s %17s %12s %12s %9s %6s %6s %3s ' ,'delimiter', '', 'whitespace', ''); data_received = received{:}
urlmidstep
's function "search", in order able create temporary .dat file. data stored in urldata
, long char array. when use textscan
in matlab, 12 columns desired, stored in cell array data_received
.
however, in octave various warning messages: warning: strread: field width '%5s' (fmt spec # 1) extends beyond actual word limit
(for various field widths). question is, why result different in octave , how fix this? shouldn't octave behave same matlab, in theory differences should dealt bugs?
surely specifying width of strings , leaving both delimiter , whitespace input arguments empty should tell function deal width of string, allowing spaces valid characters.
any appreciated.
i thinhk textscan
works differently in matlab , octave. illustrate let's simplify example. code:
test_line = 'k05p00m c2003 01 28.38344309 37 57.87 +11 05 14.9 n~1hzv645'; test = textscan(test_line,'%5s','delimiter',''); test{:}
will yield following in matlab:
>> test{:} ans = 'k05p0' '0m c' '2003 ' '01 28' '.3834' '4309 ' '37 57' '.87 +' '11 05' '14.9 ' 'n~1hz' 'v645'
whereas in octave, get:
>> test{:} ans = { [1,1] = k05p0 [2,1] = c2003 [3,1] = 01 [4,1] = 28.38 [5,1] = 37 [6,1] = 57.87 [7,1] = +11 [8,1] = 05 [9,1] = 14.9 [10,1] = n~1hz }
so looks octave jumps next word , discards remaining character in current word, whereas matlab treats whole string 1 continuous word.
why , 1 correct, not know, it'll point in right direction understanding going on. can try adding delimiter
see how affects results.
Comments
Post a Comment