Read data couples from txt file

1 Ansicht (letzte 30 Tage)
Sara Satanassi
Sara Satanassi am 17 Nov. 2017
Beantwortet: KL am 18 Nov. 2017
Hello everyboby I'm pretty new on Matlab and I've got a simple question: I have to read some data couples from text file as formatted:
"51361"\t"64400"\r "51361"'\t'"29911"\r . . . "64400"'\t'"29911"\r "64400"'\t'"1488"\r
My goal is to put this couples in two different arrays as shown:
s = [51361, 51361,..., 64400, 64400] t = [64400, 29911,..., 29911, 1488]
could someone help me with the code?
Thank you very much.
Sara

Antworten (1)

KL
KL am 18 Nov. 2017
Does your file also have the double quotation mark and \t,\r as you have written? If not, something as simple as,
data = dlmread('filename.txt')
but output will be a matrix with two columns
if it's indeed including the double quotations and symbols and you just want to import the numbers, I'd recommend using textread
here you have to specify your format string and you can import them into separate variables,

Kategorien

Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by