how to make a timestamp for plotting out of (m:s:ms) ?

2 ビュー (過去 30 日間)
Kaan Inal
Kaan Inal 2021 年 9 月 19 日
コメント済み: Kaan Inal 2021 年 9 月 23 日
Hello,
I have an application which gets timevalues ( minutes,seconds,milliseconds) over TCP. This values are generated inside the module which sends data to matlab.
Now i want to convert this values to a timestamp to do some plotting. How can I archive this?
I tried this:
%save Data in Matrix
%make timestamp for plotting data.
timestamp = datetime(0,0,0,0,app.minute,app.second,app.millisecond);
%Save data in matrice for further operations(plotting,saving)
app.x(app.counter,:)=[timestamp,accx,accy,accz,eulx,euly,eulz];
app.counter = app.counter + 1;
But it didn't work.
Thank you very much.
  2 件のコメント
Siddharth Bhutiya
Siddharth Bhutiya 2021 年 9 月 21 日
Just based on the information in your question, it seems that you are working with time periods rather than date times. So it seems logical to use duration instead of datetime.
timestamp = duration(0,app.minute,app.second,app.millisecond);
What are the data types of your other values (app.x, accx, accy, eulz, etc.) assuming they are doubles, then you are trying to mix different types in an array which is not supported. When trying to store heterogeneous types you could use table or better timetables since your data seems to be timestamped.
It is difficult to infer a lot just from few lines of code. If you are still stuck then please include some sample data on what each value described in your code looks like and also the exact errors that you are getting. Having more context about the code and data would make it easier for people to provide suggestions.
Kaan Inal
Kaan Inal 2021 年 9 月 23 日
Thank you very much!
I now used array2timetable like this
%create timetable
array2timetable(app.BNO055Messung(:,4:13),'Samplerate',100,"VariableNames",{'acc_x','acc_y','acc_z','eul_x','eul_y','eul_z','quat_w','quat_x', 'quat_y', 'quat_z'});
%save table as .txt file
saveTimeTable(app,app.BNO055TimeTable,app.TimeTableEditField.Value);
Now i have a .tx file looking like this:
Time,acc_x,acc_y,acc_z,eul_x,eul_y,eul_z,quat_w,quat_x,quat_y,quat_z
0 sec,-0.36,-0.4,9.39,6.875,-1.8125,2.5,0.997802734375,-0.02130126953125,0.017333984375,-0.0599365234375
0.01 sec,-0.35,-0.38,9.38,6.875,-1.8125,2.5,0.997802734375,-0.02130126953125,0.017333984375,-0.0599365234375
0.02 sec,-0.33,-0.39,9.38,6.875,-1.8125,2.5,0.997802734375,-0.02130126953125,0.017333984375,-0.0599365234375
Now i want to LOAD this txt file and save it again in a variable of type timetable for plotting and analysis.
But the following code doesnt work:
TT = readtimetable(app.FilenameEditField.Value,"RowTimes",'Time',"DurationType","duration");
Error message: Error using readtimetable (line 284)
Row times must be datetime or duration vector.
Thank you for your help!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by