How to combine data from 3 different arrays?
4 views (last 30 days)
Show older comments
Hello,
I basically have survey data with 3 different groups/files, and I am trying to figure out how to combine them all together. The problem is that they are 4d, and each group has a different amount of people, so I am unsure how to add them together. The first 3 dimensions are the same, it is just the last dimension of the number of people that is different? Any help would be appreicated!
3 Comments
Accepted Answer
Voss
on 7 Feb 2023
You can cat along the 4th dimension. Here's an example with random data:
A = 10;
B = 5;
C = 8;
G1 = 3;
G2 = 6;
G3 = 7;
data1 = rand(A,B,C,G1);
data2 = rand(A,B,C,G2);
data3 = rand(A,B,C,G3);
result = cat(4,data1,data2,data3);
size(result)
2 Comments
Voss
on 7 Feb 2023
You're welcome! Any questions, please let me know; otherwise, please Accept this Answer. Thanks!
More Answers (0)
See Also
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!