Read data couples from txt file
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposte (1)
KL
il 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,
0 Commenti
Vedere anche
Categorie
Scopri di più su Workspace Variables and MAT Files in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!