Improve result of text file

Hello
I´m having a hard time to understand why I can’t make the result look better. I want to remove the “” and make 18659 Gamble, John.
Test.txt:
Gamble, John 18659
Fire, Jack 58213
Ace, Danille 62356
Code:
clc
fid = fopen('test.txt', 'r');
R = textscan(fid,'%s %s %s');
B = [R{3},R{1:2}];
fclose(fid);
disp(B)
Result:
18659<space> Gamble<space>John

답변 (1개)

Cedric
Cedric 2013년 3월 25일
편집: Cedric 2013년 3월 25일

0 개 추천

If you evaluate
class(R{3})
class(R{1:2})
you will realize that these are cells/arrays. You need to index one step further to get the content, otherwise B is a cell array, which is what DISP displays currently.

카테고리

도움말 센터File Exchange에서 Language Support에 대해 자세히 알아보기

질문:

R
R
2013년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by