how do i convert a dataset to matrix?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Postit123
el 12 de Nov. de 2020
Respondida: Star Strider
el 12 de Nov. de 2020
hello
I'd like to change a file below to the matrix.
I tried to use fscanf, but got stuck in the formatspec.
Do you know how to choose formatspec or is there any other way to convert those data to the matrix?
Thank you.
$GPGGA,074435.00,3736.07160,N,12651.98574,E,1,08,0.00,10.4,M,,,,*34
$GPRMC,074435.00,A,3736.07160,N,12651.98574,E,0.000,201.2,121120,,,A*58
$GPGGA,074436.00,3736.07194,N,12651.98555,E,1,08,0.00,10.4,M,,,,*3F
$GPRMC,074436.00,A,3736.07194,N,12651.98555,E,1.305,206.9,121120,,,A*58
$GPGGA,074437.00,3736.07208,N,12651.98501,E,1,08,0.00,10.4,M,,,,*39
$GPRMC,074437.00,A,3736.07208,N,12651.98501,E,1.350,209.1,121120,,,A*59
$GPGGA,074438.00,3736.07210,N,12651.98555,E,1,08,0.00,10.4,M,,,,*3E
$GPRMC,074438.00,A,3736.07210,N,12651.98555,E,0.615,213.7,121120,,,A*56
$GPGGA,074439.00,3736.07180,N,12651.98607,E,1,08,0.00,10.4,M,,,,*31
$GPRMC,074439.00,A,3736.07180,N,12651.98607,E,0.292,213.8,121120,,,A*5D
$GPGGA,074440.00,3736.07124,N,12651.98615,E,1,08,0.00,10.4,M,,,,*32
$GPRMC,074440.00,A,3736.07124,N,12651.98615,E,0.354,210.6,121120,,,A*58
$GPGGA,074441.00,3736.07092,N,12651.98645,E,1,08,0.00,10.4,M,,,,*3A
$GPRMC,074441.00,A,3736.07092,N,12651.98645,E,0.531,213.3,121120,,,A*53
$GPGGA,074442.00,3736.07058,N,12651.98662,E,1,08,0.00,10.5,M,,,,*3B
$GPRMC,074442.00,A,3736.07058,N,12651.98662,E,0.640,210.8,121120,,,A*5E
$GPGGA,074443.00,3736.07018,N,12651.98647,E,1,08,0.00,10.5,M,,,,*39
$GPRMC,074443.00,A,3736.07018,N,12651.98647,E,0.693,214.4,121120,,,A*5A
$GPGGA,074444.00,3736.06975,N,12651.98598,E,1,08,0.00,10.5,M,,,,*3C
$GPRMC,074444.00,A,3736.06975,N,12651.98598,E,0.746,212.1,121120,,,A*55
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Nov. de 2020
Using two lines of the posted file, this textscan call appears to read each of them (presented individually, since I prefer not to attempt to reconstruct the file):
s = '$GPRMC,074435.00,A,3736.07160,N,12651.98574,E,0.000,201.2,121120,,,A*58';
s = '$GPGGA,074435.00,3736.07160,N,12651.98574,E,1,08,0.00,10.4,M,,,,*34';
C = textscan(s, '%s %f %s %f %s %f %s %f %f %f %s', 'Delimiter',',', 'MultipleDelimsAsOne',1)
It will be necessary to include fopen (and fclose) calls in the script that uses this, and then appropriately use the individual cells in the rest of the code. I avoided using 'CollectOutput' here because I have no idea what the fields represent.
.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Text Files en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!