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.

 채택된 답변

Voss
Voss 2023년 11월 10일

0 개 추천

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

Jose Jaquez
Jose Jaquez 2023년 11월 10일
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 2023년 11월 10일
Wait nevermind, I forgot to edit it and delete the arrows, Thank you!!
Voss
Voss 2023년 11월 10일
편집: Voss 2023년 11월 10일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Labels and Annotations에 대해 자세히 알아보기

태그

질문:

2023년 11월 10일

편집:

2023년 11월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by