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

조회 수: 1 (최근 30일)
pink flower
pink flower 2020년 4월 14일
댓글: Akira Agata 2020년 4월 15일
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
Akira Agata
Akira Agata 2020년 4월 15일
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?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Agriculture에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by