How to convert a time series data to txt file?

조회 수: 27 (최근 30일)
James Pinto
James Pinto 2022년 11월 1일
답변: Lei Hou 2022년 11월 18일
I have a time series data saved during simulation. How to convert it to a txt file?
  댓글 수: 1
KSSV
KSSV 2022년 11월 1일
How is your data? Is it saved in other format?

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

답변 (2개)

Lei Hou
Lei Hou 2022년 11월 18일
Hi James,
You can use timeseries2timetable to convert your timeseries to a timetable. Then use writetimetable to write your data to a txt file.
Thanks,
Lei

Maik
Maik 2022년 11월 1일
%% Time Series Data in to Text File
timeSeriesVector = randi([1 10],30,1);
txtFileCreate = fopen('timeSeriesVector.txt','wt');
%Comma Separated Values
fprintf(fid,'%d,',timeSeriesVector);
% Print in Separate Rows
fprintf(fid,'%d\n',timeSeriesVector);
fclose(fid);
%% Time Series Matrix File to Data File
timeSeriesArray= randi([1 10],30,30);
writematrix(timeSeriesArray,'timeSeriesArray.txt')

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by