How to add a timestamp to array in simulink?

Hello,
I have problem with adding a timestamp in simulink. I have array date (9 values) from IMU sensor like on the picture and I need to add a tenth kolumn with timestamp (with milisecond).
I have tried like on the picture below with code in matlab function:
function [Y, M, D, H, MN, S, MS] = fcn()
eml.extrinsic('now');
eml.extrinsic('datevec');
Y = 0;
M = 0;
D = 0;
H = 0;
MN = 0;
S = 0;
MS = 0;
[Y, M, D, H, MN, S, MS] = datevec(now);
end
And to create a file with txt format I used a command:
dlmwrite('E:\temp.txt', sumout111,'delimiter','\t','precision',3)
When I run simulation I have error:
Ok, I have changed directory and ran as admin Matlab and I have another problem:
%

 Accepted Answer

1. If you want to run the model as a regular user, you can set the cache folder to some folde other than C:\Windows... Example:
set_param(0, 'CacheFolder', 'D:\Temp')
2. If you want to run as Admin, after the \MATLAB opens up, do mex-setup and select host compiler(lcc or MSVC++) : Reason: For each profile, the mex settings are stored separately.

More Answers (1)

plaziok
plaziok on 2 Aug 2017
Edited: plaziok on 2 Aug 2017
It works. Thanks a lot.
And I had to delete 'MS' from code because datavec returns only 6 values. Datevec returns milliseconds as a fractional part of the seconds (S) output (for example 15.6).

Categories

Products

Asked:

on 2 Aug 2017

Edited:

on 2 Aug 2017

Community Treasure Hunt

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

Start Hunting!