Repeating array row n times with change of indexes

조회 수: 1 (최근 30일)
Joanna Widzinska
Joanna Widzinska 2019년 9월 12일
답변: Joanna Widzinska 2019년 9월 24일
Hello everyone,
I have matrix of 1 minute data of the household load (5760x2, where 1st column reflects minutes and second the load). I need to transform data into seconds, where every row will be repeated 60 times with the change of indexes.
Ex.
1min x1 1 x1
2min x2 -----------------> 2 x1
... .....
5760min x5760 60 x1
61 x2
...
120 x2 etc.
I tried many different options and now I think it's involved in multiplying the matrices, but I can't solve this properly.
Can somebody help me? Thanks!

채택된 답변

Shubh Sahu
Shubh Sahu 2019년 9월 18일
Hello Jonna,
Let us suppose, the household data is in ‘a’, to repeat the number of rows repelem function is used:
u(:,2) = repelem(a(:,2),[60]);
u(:,1)=1:(5760*60);
for more information regarding repelem refer the following link:
  댓글 수: 3
Shubh Sahu
Shubh Sahu 2019년 9월 19일
Have a look on this, may it explains
clc;
clear all;
close all;
a=[1,5;2,7;3,8];% take a 3*2 matrix
u(:,2) = repelem(a(:,2),[60]);
u(:,1)=1:(size(a,1)*60);
madhan ravi
madhan ravi 2019년 9월 19일
+1

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

추가 답변 (1개)

Joanna Widzinska
Joanna Widzinska 2019년 9월 24일
It worked! Thank you very much :)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by