How to merge two variables together in a table
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Blue
am 2 Feb. 2022
Beantwortet: Cris LaPierre
am 2 Feb. 2022
Hi, I have a quick question : I have an initial table T and I would like to merge the variables deph1 and deph2 into a single new variable called deph as shown in the desired output (T1).
% Initial table
set_no = [1, 2, 3]';
deph1 = [123, 125, 150]';
deph2 = [124, 126, 148]';
T = table(set_no, deph1, deph2)
% Desired output
set_no = [1, 1, 2, 2, 3, 3]';
deph = [123, 124, 125, 126, 150, 148]';
T1 = table(set_no, deph)
Any ideas ?
Thank you,
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 2 Feb. 2022
% Initial table
set_no = [1, 2, 3]';
deph1 = [123, 125, 150]';
deph2 = [124, 126, 148]';
T = table(set_no, deph1, deph2)
% Desired output
T1 = stack(T,["deph1","deph2"])
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!