Improve result of text file
Ältere Kommentare anzeigen
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)
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
Mehr zu Language Support finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!