I have this text file with time stamps and with values that I am trying to plot. I am not well versed in MatLab to even begin writing a code.

 Réponse acceptée

Voss
Voss le 10 Nov 2023
filename = 'Data1.txt';
T = readtable(filename)
T = 73×2 table
Var1 Var2 ____________ _______ 11:26:42.028 -178.39 11:26:42.126 175.5 11:26:42.265 -170.07 11:26:42.345 -172.13 11:26:42.428 179.11 11:26:42.526 179.7 11:26:42.629 177.88 11:26:42.759 169.8 11:26:42.849 161.06 11:26:42.945 -177.34 11:26:43.068 -170.62 11:26:43.146 -172.11 11:26:43.278 -177.71 11:26:43.362 173.86 11:26:43.451 168.34 11:26:43.555 170.14
plot(T.(1),T.(2))

3 commentaires

Jose Jaquez
Jose Jaquez le 10 Nov 2023
Okay great! this worked! But I tried using this same code for a different file and I got an error.
Error using plot
Invalid data argument.
Error in AccelerometerGraph (line 3)
plot(T.(1),T.(2))
Jose Jaquez
Jose Jaquez le 10 Nov 2023
Wait nevermind, I forgot to edit it and delete the arrows, Thank you!!
Voss
Voss le 10 Nov 2023
Modifié(e) : Voss le 10 Nov 2023
You're welcome!
You can avoid deleting the arrows from the text file, if that's more convenient. The file is read just fine by readtable, so all you have to do is plot with the 3rd column instead of the 2nd:
filename = 'Data2.txt';
T = readtable(filename)
T = 86×3 table
Var1 Var2 Var3 ____________ ______ _______ 10:18:28.544 {'->'} -170.58 10:18:28.672 {'->'} -155.68 10:18:28.761 {'->'} -173.08 10:18:28.863 {'->'} 178.71 10:18:28.949 {'->'} 174.53 10:18:29.093 {'->'} 169.34 10:18:29.184 {'->'} 169.8 10:18:29.277 {'->'} 170.72 10:18:29.375 {'->'} 173.62 10:18:29.458 {'->'} 177.41 10:18:29.596 {'->'} -178.71 10:18:29.680 {'->'} -172.09 10:18:29.797 {'->'} -170.26 10:18:29.899 {'->'} -171.57 10:18:29.981 {'->'} -170.6 10:18:30.078 {'->'} -176.27
plot(T.(1),T.(3)) % plot third column vs first column

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Labels and Annotations dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by