Exporting .txt file with timestamp for live data.
3 views (last 30 days)
Show older comments
Hello,
I'm currently measuring roll, yaw, and pitch on my imu sensor in live time. I'm exporting a file as a 3 column txt file for x,y, and z. I want to add a time stamp for an additional column, for each set of data that I get. How would I go about this? Here's a snippet of my current code. Thanks in advanced.
%%
interv=50;
init_time=1;
x=0;
y=0;
z=0;
while(init_time<interv)
b=ez.CurrentData.YawPitchRoll.X;
c=ez.CurrentData.YawPitchRoll.Y;
d=ez.CurrentData.YawPitchRoll.Z;
x=[x,b]; %roll
y=[y,c]; %pitch
z =[z,d]; %yaw
plot(x, 'r')
plot(y,'k')
plot(z,'b')
title('IMU Orientation Test')
xlabel('Time (s)')
ylabel('\theta')
legend('Roll','Pitch','Yaw')
ylim([-200 200])
xlim([0 interv])
grid on
hold on
drawnow
init_time=init_time+1;
end
dlmwrite('VectorNav.txt',[x' y' z'],'newline','pc')
4 Comments
Brendan Hamm
on 30 Nov 2018
If you mean the current timestamp at run time:
d = datetime('now')
You may wish to tchange the display format if your code is running fairly quickly:
d = datetime('now','Format','dd-MMM-yyyy HH:mm:ss.SS')
Answers (0)
See Also
Categories
Find more on External Language Interfaces in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!