How to join two matrices together

1 次查看(过去 30 天)
Moe
Moe 2015-6-26
编辑: Moe 2015-6-26
I have two for loops that in each iteration is producing n & m series of data for Start_MS (i) & Duration_MS (i) & Start_DS (j) & Duration_DS (j).
n = randi([1, 5]);
for i=1:n
Start_MS (i) = rand();
Duration_MS (i) = Start_MS (i) +12;
end
m = randi([1, 6]);
for j=1:m
Start_DS (j) = rand();
Duration_DS (j) = Start_DS (j) +12;
end
I want to bring all of the output in one matrix that started with first loop and followed by second loop. Also, first column to be Start_MS (!) and second column is Duration_SW (!) [! = i or j]. For example if n is 2 & m is 3, then:
Output: [3,14;5,18;7,10;5,10;2,16];
Furthermore, I need another description name matrix such that just name of array appear on it. For example if n is 2 % m is 3, then:
Legend = {'Start_MS','Duration_MS','Start_MS','Duration_MS','Start_DS','Duration_DS','Start_DS','Duration_DS''Start_DS','Duration_DS'};

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by