# How to repeat sample data in minutes?

6 Ansichten (letzte 30 Tage)
fatin anuwar am 20 Mär. 2018
Bearbeitet: Andrei Bobrov am 22 Mär. 2018
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 KommentarKeine anzeigenKeine ausblenden
Guillaume am 20 Mär. 2018
Bearbeitet: Guillaume am 20 Mär. 2018
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

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Andrei Bobrov am 20 Mär. 2018
Bearbeitet: Andrei Bobrov am 22 Mär. 2018
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');
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'});
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

KL am 20 Mär. 2018
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
...
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
KL am 20 Mär. 2018
Thanks Guillaume, I didn't know this.

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by