# How to make a single array of values from multiple different arrays one after the other

3 visualizaciones (últimos 30 días)
Claire el 16 de Feb. de 2021
Comentada: Claire el 18 de Feb. de 2021
Hello!
I have one array, A, with serial dates from a range of dates and the same time for each date, so like for every day of one month in one year at 1:30 AM. I have another array, B, with serial dates of that same date range from that same month and year at a different time but all at 4:30 PM instead. I have another array C, with the same date range but at 11:30 pm. I want to combine all these arrays into one so that they are one large array with the dates and times in order which would be one value from A then another from B, then the next from C, then the next from A, and so on like A B C A B C A B C...
Sorry if this was unclear, thank you!
##### 2 comentariosMostrar NingunoOcultar Ninguno
David Hill el 16 de Feb. de 2021
Recommend providing a sample of your arrays. Recommend converting using datenum().
Claire el 16 de Feb. de 2021
Editada: Claire el 18 de Feb. de 2021
Here is a sample of my arrays:
A B C
736055.063 736055.521 736055.896
736056.063 736056.521 736056.896
736057.063 736057.521 736057.896
I would like to combine them into one array that would look something like this:
Full array (serial date from A, followed by serial date from B, followed by serial date from C, on repeat until it is the length of the 3 arrays combined)
736055.063 A
736055.521 B
736055.896 C
736056.063 A
736056.521 B
736056.896 C
736057.063 A
736057.521 B
736057.896 C
edit: example of desired, full array was incorrect, now fixed!

Iniciar sesión para comentar.

KALYAN ACHARJYA el 17 de Feb. de 2021
You canot combine numeric and strings together in an Array, You may do the same using cell array. Another way using table
A=[736055.063,736056.063,736057.063];
B=[736055.521,736056.521,736057.521];
C=[736055.896,736056.896,736057.896];
data=[A',B',C'];
dat=data(:);
cate=['A','B','C']';
r=length(dat)/length(cate);
col2=repmat(cate,[r,1]);
t=table(dat,col2)
Result:
t =
9×2 table
dat col2
__________ ____
736055.063 A
736056.063 B
736057.063 C
736055.521 A
736056.521 B
736057.521 C
736055.896 A
736056.896 B
736057.896 C
##### 2 comentariosMostrar NingunoOcultar Ninguno
KALYAN ACHARJYA el 18 de Feb. de 2021
Editada: KALYAN ACHARJYA el 18 de Feb. de 2021
Here:
A=[736055.063,736056.063,736057.063];
B=[736055.521,736056.521,736057.521];
C=[736055.896,736056.896,736057.896];
data=reshape([A;B;C],size(A,1),[]);
dat=data(:);
cate=['A','B','C']';
r=length(dat)/length(cate);
col2=repmat(cate,[r,1]);
t=table(dat,col2)
Result:
t =
9×2 table
dat col2
__________ ____
736055.063 A
736055.521 B
736055.896 C
736056.063 A
736056.521 B
736056.896 C
736057.063 A
736057.521 B
736057.896 C
Claire el 18 de Feb. de 2021
Thank you this works perfect!

Iniciar sesión para comentar.

### Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

### Community Treasure Hunt

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

Start Hunting!

Translated by