Exporting .txt file with timestamp for live data.

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 commentaires

dpb
dpb le 17 Nov 2018
For what time--each sample or for the dataset as a whole? Is this just a polling operation or are is the device sampling at a known rate and you're just returning those values?
sorry for the delayed response, but i want to add a time stamp next to each data point during live time testing. For ex; if i have 200 data points, then i would like to have 200 separate time stamps for each data point in my txt file in a 4th column
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')
Thank you kind sir :D

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur External Language Interfaces dans Centre d'aide et File Exchange

Tags

Commenté :

le 30 Nov 2018

Community Treasure Hunt

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

Start Hunting!

Translated by