reading the file using input function

i have a word saves in text file 'hello23,hi10'.name of textfile is new.txt,is there any input function to read and display
hello23 hi10

 Akzeptierte Antwort

TAB
TAB am 3 Jan. 2012

0 Stimmen

If your file contains data like this
hello23,hi10
hello24,hi11
hello25,hi12
....
You can combine read and replacement commands as
strrep(textread('new.txt','%s'),',',' ')
It will return cell array having strings without ','
[EDITED] Using textscan()
f=fopen('new.txt');
arrayfun(@(x) strrep(x{1},',',' '),textscan(f,'%s'),'UniformOutput',false)
fclose(f);

2 Kommentare

Walter Roberson
Walter Roberson am 3 Jan. 2012
Note: textread() is considered obsolete, and will probably be deleted soon.
TAB
TAB am 4 Jan. 2012
textscan() can be used as a replacement of textread();

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Friedrich
Friedrich am 3 Jan. 2012

0 Stimmen

Hi,
you can do something like:
strrep(fileread('new.txt'),',',' ')

Kategorien

Mehr zu Large Files and Big Data finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 3 Jan. 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by