doubt regarding textscan

Asked by muthu kumar on 24 May 2012
Latest activity Commented on by muthu kumar on 28 May 2012

hello friends i want to read a file which contains a long number and i have to store in for further processing, ex 2.6300000000000000e+002 2.2500000000000000e+002() like this . i think it is a exp data ,i tried using textscan(fid,'%f %f')but no result i am waiting for ur help

0 Comments

muthu kumar

Products

No products are associated with this question.

1 Answer

Answer by per isakson on 24 May 2012
Accepted answer

What do you mean by "no result"? What value does fid have? This little test works fine!

    str = '2.6300000000000000e+002 2.2500000000000000e+002';
    cac = textscan( str,'%f %f');
    >> cac{:}
    ans =
       263
    ans =
       225

3 Comments

muthu kumar on 28 May 2012

first up all thank for ur reply, but in the input is a txt file which contain like this data many rows like
2.6300000000000000e+002 2.2500000000000000e+002
2.6300000000000000e+002 2.2500000000000000e+002
2.6300000000000000e+002 2.2500000000000000e+002 which is a coordinate(x y) of points in face image

Walter Roberson on 28 May 2012

What result do you get from textscan() ? Do you get an error message?

muthu kumar on 28 May 2012

thank u i got it
the code is
function [c]= file11(arg)
fi=fopen(arg,'r');

c=textscan(fi,'%f %f');

fclose(fi);
main file is
fid = fopen('test.txt');

tline = fgetl(fid);
k=1;
images = cell(1, 2);
while ischar(tline)

disp(tline)

images{k}= file11(tline);
k=k+1;
tline = fgetl(fid);
end
disp([images{:}]);
fclose(fid);
it reads given no of files and it stores the contents in cell array

thank for ur guidence

per isakson

Contact us