Change data that adds one row per iteration into one single matrix of all rows

1 view (last 30 days)
n=n+1;
table(n,1) = theta2;
table(n,2) = theta3;
table(n,3) = r31;
table(n,4) = theta4;
table(n,5) = r5;
table(n,6) = det_1;
table(n,7) = det_2;
table(n,8) = theta3_prime;
table(n,9) = r31_prime;
table(n,10) = theta3_dprime;
table(n,11) = r31_dprime;
table(n,12) = det1_vmatrix;
table(n,13) = theta4_prime;
table(n,14) = r5_prime;
table(n,15) = theta4_dprime;
table(n,16) = r5_dprime
table(n,17) = det2_vmatrix;
I would like to have one matrix of all of this data instead of multiple matrices that only add one row at a time. The input of the for loop is theta2=0:10:360; Here is an example of what the command window returns table =
Columns 1 through 13
0 196.5783 105.8701 143.1301 100.0000 137.4727 200.0000 0.6300 -41.5101 0.0556 23.9650 137.4726 0.4330
Columns 14 through 16
-28.5325 -0.1406 41.4063
table =
Columns 1 through 13
0 196.5783 105.8701 143.1301 100.0000 137.4727 200.0000 0.6300 -41.5101 0.0556 23.9650 137.4726 0.4330
10.0000 202.9118 99.0044 148.1048 114.5428 120.6135 200.0000 0.6351 -37.0537 0.0007 27.8404 120.6088 0.3609
Columns 14 through 17
-28.5325 -0.1406 41.4063 200.0000
-21.0550 -0.1629 49.3192 0

Accepted Answer

Star Strider
Star Strider on 29 Sep 2014
I am not certain I understand what you want, but you could do this:
for n = 1:N
table(n,:) = [theta2 theta3 r31 theta4 r5 det_1 det_2 theta3_prime r31_prime det1_vmatrix theta4_prime r5_prime theta4_dprime det2_vmatrix];
end
where ‘N’ is the number of times you want to loop through it.
If each of these values are vectors themselves, then instead of the loop, convert each to a column vector and use one statement:
table = [theta2 theta3 r31 theta4 r5 det_1 det_2 theta3_prime r31_prime det1_vmatrix theta4_prime r5_prime theta4_dprime det2_vmatrix];
  4 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Operating on Diagonal 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!