Exporting .txt file with timestamp for live data.
Afficher commentaires plus anciens
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
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?
John Andrew
le 30 Nov 2018
Brendan Hamm
le 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')
John Andrew
le 30 Nov 2018
Réponses (0)
Catégories
En savoir plus sur External Language Interfaces dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!