Hello, I plot the first column and fourth column of this txt file time series data and there are some empty data . how can I know what percentage of the empty data and interpolate the data?

 採用された回答

Walter Roberson
Walter Roberson 2022 年 7 月 31 日

0 投票

You might want to choose a different aggregation method such as 'minutely'
format long g
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/1083480/cbrn2020.txt';
data = readtable(filename);
data{1:5,1}
ans = 5×1
1.0e+00 * 2019.99863013699 2019.99863964992 2019.99864916286 2019.9986586758 2019.99866818874
tt = table2timetable(data, 'RowTimes', datetime(0,0,0) + years(data{:,1}));
ttt = retime(tt(:,4), 'daily', 'sum');
ttt(1:5,:)
ans = 5×1 timetable
Time Var4 ___________ ________________ 29-Nov-2019 504.559662800325 30-Nov-2019 771.212892908936 01-Dec-2019 772.532087984068 02-Dec-2019 773.057727623874 03-Dec-2019 763.898137033537
plot(ttt, 'Var4')

7 件のコメント

Anak Agung Adhi Dermawan
Anak Agung Adhi Dermawan 2022 年 7 月 31 日
Yes, but I need it daily. So we can't interpolate the data?
Walter Roberson
Walter Roberson 2022 年 7 月 31 日
The above code already summarizes daily.
You can interpolate if you want; provide the interpolation method instead of 'sum' .
But are you sure it is a good idea to interpolate February results all the way over to July ?
Anak Agung Adhi Dermawan
Anak Agung Adhi Dermawan 2022 年 8 月 2 日
I think I don' need to interpolate the data sir. But, when we plot it, how can we know how many empty data in points/percentage?
Walter Roberson
Walter Roberson 2022 年 8 月 2 日
numempty = sum(isnan(ttt.Var4));
percentempty = numepty / height(ttt) * 100;
Anak Agung Adhi Dermawan
Anak Agung Adhi Dermawan 2022 年 8 月 2 日
thank you very much sir
Anak Agung Adhi Dermawan
Anak Agung Adhi Dermawan 2022 年 8 月 3 日
Sir, I can only plot the timetable data using stackedplot command, how can I plot the Var4 data with different aggregation and resample result with hold on command?
Walter Roberson
Walter Roberson 2022 年 8 月 4 日
You can always extract data, such as
ttt.Var4
You can do things like,
aggregations = {'hourly', 'daily', 'monthly'};
for K = 1 : length(aggrevations)
ttt = retime(tt(:,4), aggrevations{K}, 'sum');
plot(ttt.Properties.RowTimes, ttt.Var4, 'DisplayName', aggrevations{K});
hold on
end
hold off
legend show

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeInterpolation についてさらに検索

製品

リリース

R2021b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by