How to save the data with the day, month and year data information?

1 view (last 30 days)
Hi. I have an .m file that opens binary data and extracts soil information from it and divides the values ​​found by 6. Then I save the soil_end information in a txt file.
fid = fopen('saved_data.txt', 'w'); % open the output .txt file for writing
file = dir('*.dat');
for ii = 1:length(file)
data = fopen(file(ii).name);
soil = fread(data, [1000 1000], 'float32');
teste = find(soil<0);
soil(teste) = NaN;
soil_end = soil/6;
fprintf(fid, '%f\n', soil_end); % this will save the value in the soil variable to the .txt file
end
fclose(fid) % close the output .txt file
The names of the binary files look like this: 201701010018.dat, that is, year (2017), month (01), day (01), hour (00), minute (18). The minute, hour, day and month change. I need to save two columns in the file: one column with the year, month, day, hour and minute data and the other with the soil data. How can I do this? I want it to look like this example:
2017-01-01 00:18 0.85
2017-01-01 02:00 0.91
  1 Comment
Akira Agata
Akira Agata on 15 Apr 2020
I would recommend saving all the loaded data in table or timetable variable, and save it in output .txt file using writatable or writetimetable function.
If possible, could you upload some of your .dat files to try?

Sign in to comment.

Answers (0)

Categories

Find more on Agriculture 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!