Combining two sets of data into a singular array

조회 수: 11 (최근 30일)
Sean Leonard
Sean Leonard 2019년 7월 13일
답변: infinity 2019년 7월 13일
If I have two sets of arrays in a for loop - time and velocity data at that time point, as below.
How do I go about combining all 5 time x data into a singular array of 10 columns, with time and data of the first trial in the first two columns and time and data of the second trial in the third and fourth columns?
clear
clc
for ii=1:5
time=randn(1001,1);
data1=randn(1001,1);
combine=[time data1]
end
I was able to combine them so the time is in the first five and the data is in the second five however that makes it too confusing to read.
Any help greatly appreciated!

답변 (1개)

infinity
infinity 2019년 7월 13일
Hello,
How about if you can combine into matrix with many column like this
for ii=1:5
time=randn(5,1);
data1=randn(5,1);
combine=[time; data1]
end
So, the 1,3,5,7 and 9 column are the time of the first trial, and 2, 4, 6, 8 and 10 are velocity of the first trial. So on.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by