Hi
i am using text scan to read number 0012 but it is only reading it as 12.
fid1=fopen('input.dat','r') C=textscan(fid1,'%f',1); fclose(fid1);
i am using text scan as shown above.
Actually i want this number to be read as string. so right now i read the number and convert it to string. so any suggesstions in this case.
hope i have explained the question well

 채택된 답변

Thomas
Thomas 2012년 5월 14일

0 개 추천

try
fid1=fopen('input.dat','r');
C=textscan(fid1,'%s');
fclose(fid1);
%Edit
out=cell2mat(C{1}) % this is ur string displayed

댓글 수: 4

Haris Hameed
Haris Hameed 2012년 5월 14일
it is giving me
'0012'
is there any way i can omit the ' ' inverted comma
Thomas
Thomas 2012년 5월 14일
out=cell2mat(C{1})
Jan
Jan 2012년 5월 14일
The quote characters are not part of the data, but only displayed in the command window, if a cell is printed, which contains strings.
Haris Hameed
Haris Hameed 2012년 5월 14일
got it ! thankx

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2012년 5월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by