Reading a text file in MATLAB? -


i have text file has contents follows.. need read file column wise (ies, 2 columns here). have tried many ways.. cannot contains "(" , "," , ")" etc... please guide..

(-2.714141687294326, 0.17700122506478025) (-2.8889905690592976, 0.1449494260855578) (-2.74534285564141, 0.3182989792519164) (-2.728716536554531, -0.3267545129349194) (-2.280859632844493, -0.7413304490629143) (-2.8205377507406095, 0.08946138452856946) (-2.6261449731466335, -0.16338495969832847) (-2.8863827317805537, 0.5783117541867042) (-2.6727557978209546, 0.11377424587411682) (-2.5069470906518565, -0.6450688986485736) (-2.6127552309087236, -0.01472993916137419) (-2.7861092661880185, 0.23511200020171835) (-3.2238037438656533, 0.5113945870063824) (-2.6447503899420304, -1.1787646364375748) 

try this:

x = importdata('filename.txt'); x = regexp(x,'-?\d+\.?\d*','match'); %// detect numbers [-]a[.][bcd] x = cellfun(@str2num, vertcat(x{:})); 

if file can contain numbers in decimal form ("1.234") , in scientific notation ("1.234e-56"):

x = importdata('filename.txt'); x = regexp(x,'-?\d+\.?\d*(e-?\d+)?','match'); x = cellfun(@str2num, vertcat(x{:})); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -