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

Antworten (1)

Cedric
Cedric am 25 Mär. 2013
Bearbeitet: Cedric am 25 Mär. 2013

0 Stimmen

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.

Kategorien

Gefragt:

R
R
am 25 Mär. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by