Azzera filtri
Azzera filtri

How do I parse this given data in matlab

1 visualizzazione (ultimi 30 giorni)
  2 Commenti
Ameer Hamza
Ameer Hamza il 8 Ott 2020
Can you attach the data as text instead of an image?
Mathieu NOE
Mathieu NOE il 8 Ott 2020
hi
are you getting this by reading a txt / ascii file ? there are plenty of possibilities to red such files with matlab
how do you get this data ?
in worst case , you 'll end up to write directly data names and values either one by one or in a more structured way (cells, arrays)
read matlab help
have a look at

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 8 Ott 2020
S = fileread('YourFileNameGoesHere.txt');
colon_matches = regexp(S, '^.*:\s*(?<v1>\S+)\s*(?<v2>\S+)', 'dotexceptnewline', 'lineanchors');
v1 = str2double({colon_matches.v1});
v2 = str2double({colon_matches.v2});
power_matches = regexp(S, '^\w+\s+(?<power>)', 'lineanchors');
p = str2double({power_matches.power});
header_vals = [v1(:), v2(:)];
power_vals = p(:);

Più risposte (0)

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!

Translated by