How to repeat sample data in minutes?

1 次查看(过去 30 天)
I have 24 hours data sampled in every 5 minutes (using data logger interval every 5 minutes). how i want to repeat my data in every minutes for 24 hours(since my data every 5 minutes).i want to do simulation every 1 minutes for 24 hours.
I'm using matlab 2015.
my example:
%%Import input from actual data
%%import excel data
irr_2016_jan_1 = xlsread('data_2016.xlsx','Jan','CF9:CF296'); % Import data from day 1 january
irr_2016_jan_1 =irr_2016_jan_1'; % transpose data
%%convert data to every minute daily
irr = zeros(1,1381); % create array of zeros for time
for i=1:1:1381
irr(i+5)= irr_2016_jan_1(j)
end
- i try to do it but im stuck here. i need help plz...thanks
  1 个评论
Guillaume
Guillaume 2018-3-20
编辑:Guillaume 2018-3-20
How is the data in the 4 missing minutes supposed to be generated? Just replicating the 1st minute, or do you want to interpolate?
What is the reason for inventing more data?
Which version of matlab are you using? Have you considered using a timetable. Whatever you want to do would be trivially done with the retime function of a timetable. edit: refer to Andrei's answer to see how easy it is with timetables

请先登录,再进行评论。

回答(2 个)

Andrei Bobrov
Andrei Bobrov 2018-3-20
编辑:Andrei Bobrov 2018-3-22
data = randi(456,288,1); % your data
time = minutes(5:5:1440)';% time of your data
T = timetable(time,data,'v',{'data'});
Tout = retime(T,minutes(0:1440)','linear');
or
last row of code:
Tout = retime(T,minutes(0:1440)','next');
ADDED [MATLAB R2015]
data = randi(456,288,1); % your data
time1 = (5:5:1440)';
time2 = (1:1440)';
F = griddedInterpolant(time1,data,'linear','linear');
T_out = array2table([time2, F(time2)],'v',{'Time','Data'});
or
ii = (1:1440)';
idx = ceil(ii/5);
time2 = (1:1440)';
T_out2 = array2table([time2,data(idx)],'v',{'Time','Data'});

KL
KL 2018-3-20
Your variable name looks like you're working with irradiation, in that case I wouldn'r recommend interpolation for your simulation. You should rather get data with 1-minute resolution. If you simply want to repeat the same value 5 times, here is an example,
%create a dummy variable A
>> A = (1:5).'
A =
1
2
3
4
5
%now do the repmat and reshape
>> AA = reshape(repmat(A,1,5).',[],1)
AA =
1
1
1
1
1
2
2
2
2
2
3
3
3
...

类别

Help CenterFile Exchange 中查找有关 Data Preprocessing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by