|
|
Analyse .txt data with Matlab |
|
qurkas_physics |
Forum-Newbie
|
|
Beiträge: 3
|
|
|
|
Anmeldedatum: 27.04.18
|
|
|
|
Wohnort: ---
|
|
|
|
Version: ---
|
|
|
|
|
|
Verfasst am: 27.04.2018, 09:39
Titel: Analyse .txt data with Matlab
|
|
Good day friends,
I have a relatively difficult task and can not continue in this regard. Therefore, I hope for the support of our strong community. I have a .txt file and would like to read and analyze it. Here is a section of the .txt file. CCCC stands for letters. XXX stands for numbers. YYYY year, MM month, DD day, HH hour, MM minute, SS second, MIS millisecond. The columns are separated by | . The first eight lines are not relevant to me. I would like to create a table with the value name in the top line and below it the numbers without name are listed. The number of data is not the same for each line. I hope the task is reasonably clear and someone can help me. Thanks in advance.
Beschreibung: |
|
Download |
Dateiname: |
Forumpic.png |
Dateigröße: |
79.21 KB |
Heruntergeladen: |
715 mal |
|
|
|
|
|
salerc |
Forum-Fortgeschrittener
|
|
Beiträge: 51
|
|
|
|
Anmeldedatum: 23.04.18
|
|
|
|
Wohnort: ---
|
|
|
|
Version: R2021a
|
|
|
|
|
|
Verfasst am: 30.04.2018, 12:41
Titel:
|
|
Hi there,
could you please specify at which point you stuck with your task?
If you want to store names and values in one structure, you should use a cell array.
For saving a textfile in a cell array you can use the function textread.
If I get you right, you want to save the value after every = . So you can use strfind to find the equal signs and the | .
Between these two locations of = and | (or after = and before the end of a line) you can find the values you want to store. Like:
Does that help you or do you stuck at another point?
|
|
|
qurkas_physics |
Themenstarter
Forum-Newbie
|
|
Beiträge: 3
|
|
|
|
Anmeldedatum: 27.04.18
|
|
|
|
Wohnort: ---
|
|
|
|
Version: ---
|
|
|
|
|
|
Verfasst am: 02.05.2018, 09:36
Titel:
|
|
Many Thanks! That was very helpfull!
But could you please explain this line a bit more:
F = str2num(C{1,1}(loc1{1}(1)+1:loc2{1}(2)-1))
it works now so that the first value is written in F for example. But i would like to realize it in a loop that takes each value and then stores it in another table.
|
|
|
salerc |
Forum-Fortgeschrittener
|
|
Beiträge: 51
|
|
|
|
Anmeldedatum: 23.04.18
|
|
|
|
Wohnort: ---
|
|
|
|
Version: R2021a
|
|
|
|
|
|
Verfasst am: 02.05.2018, 12:11
Titel:
|
|
In the cell C I stored each line of your file. So you can get line i with C{i} (or C{i,1}).
In the cell loc1 I stored the positions of each equal sign in each line, so in loc1{i} I get a vector of all positions of '=' in line i. So, to get the position j in line i I need loc1{i}(j).
To get the j-th equal sign in line i I insert that position in my cell C like: C{1,1}(loc1{1}(1)). However, I don't want the equal sign but the characters after that, so I add 1.
That would mean sth like: C{1,1}(loc1{1}(1)+1:end)
My string, which I'm interested in, ends before the |, so I do the same with loc2 and subtract 1.
It's still a string, so I need str2num to get to a number format.
Just remember there is an exception at the end of a line (there is no |), so to get the last element you need sth like loc1{i}(j)+1:end.
|
|
|
|
|
Einstellungen und Berechtigungen
|
|
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
|
|
Impressum
| Nutzungsbedingungen
| Datenschutz
| FAQ
| RSS
Hosted by:
Copyright © 2007 - 2024
goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.
|
|