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

 채택된 답변

TAB
TAB 2012년 1월 3일

0 개 추천

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

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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Friedrich
Friedrich 2012년 1월 3일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

질문:

2012년 1월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by