How to change the time increment of a text file to make a new data set from an existing one?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Ryan Fishbaugh
il 13 Set 2019
Risposto: Star Strider
il 13 Set 2019
So I have a .txt file I want to load into another program, and before I do I want to change the time increment of the text file. So for example let's say I have a text file that looks like this:
Example
1.1 7 8 5
1.2 8 9 4
1.3 9 10 3
1.4 10 11 12
1.5 11 12 1
where the first column is the time, the second is the x position, the third is the y position, and the fourth is the z position.
And I'm looking to finish with a code at a different increment, say instead of .1 it's point .06
Example
1.1 7 8 5
1.16 x2 y2 z2
1.22 x3 y3 z3
1.28 x4 y4 ...
1.34 ...
1.4 ...
1.46 ...
And make that the new data in the text file.
Anyone able to provide insight on how this might be done? Thank you.
0 Commenti
Risposta accettata
Star Strider
il 13 Set 2019
A = [1.1 7 8 5
1.2 8 9 4
1.3 9 10 3
1.4 10 11 12
1.5 11 12 1];
NewCol1 = min(A(:,1)) : 0.06 : max(A(:,1));
A2 = interp1(A(:,1), A(:,2:end), NewCol1(:));
NewA = [NewCol1(:) A2]
producing:
NewA =
1.1000 7.0000 8.0000 5.0000
1.1600 7.6000 8.6000 4.4000
1.2200 8.2000 9.2000 3.8000
1.2800 8.8000 9.8000 3.2000
1.3400 9.4000 10.4000 6.6000
1.4000 10.0000 11.0000 12.0000
1.4600 10.6000 11.6000 5.4000
However, if you later want to do signal processing on your re-timed matrix, the resample function is likely more appropriate. It incorporates an anti-aliasing filter.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical 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!