How to store a matrix values in this code?

Just run my code you will get so many 'CH' values like this "CH=[150.5936 99.3701 0.9997 50.5976 ]"
and now i want to store all the values of "CH" in one matrix like
AllCH=[150.5936 99.3701 0.9997 15.6001
152.7447 102.5525 1.0000 19.3757
157.0481 132.8359 1.0000 47.7117
166.7268 123.7547 1.0000 44.6008
173.9240 81.3946 1.0000 35.2556
175.4087 73.5609 1.0000 38.9943
187.6387 98.3146 1.0000 49.2308
192.9196 45.3205 1.0000 68.7777
195.0821 71.3002 1.0000 58.2869];

2 Comments

Please use tags that are relevant to your question

Sign in to comment.

 Accepted Answer

What's stopping you from adding your CH one row at a time to AllCH?
Before the loop that calculate CH:
AllCH = [];
In the loop, after you've calculated CH:
AllCH = [AllCH; CH];

3 Comments

ya, but sir, i should not get repeated value also.
now i'm getting like this
AllCH=[6.3739 46.7388 0.9991 107.7154
174.6445 87.0270 0.9996 75.7634
148.5759 52.1945 0.9996 68.1541
89.2563 159.2453 0.9996 60.2115
57.5137 60.0198 0.9996 58.3396
92.6472 91.4933 0.9998 11.2440
39.7329 17.9399 0.9992 101.8134
57.5137 60.0198 0.9996 58.3396
89.2563 159.2453 0.9996 60.2115
57.5137 60.0198 0.9996 58.3396
85.6177 178.9929 0.9995 80.2915
85.6177 178.9929 0.9995 80.2915
39.7329 17.9399 0.9992 101.8134
149.8105 144.2425 0.9996 66.6219
174.4820 106.2654 0.9996 74.7451
121.4697 71.5445 0.9997 35.6464
92.6472 91.4933 0.9998 11.2440
89.2563 159.2453 0.9996 60.2115
149.8105 144.2425 0.9996 66.6219
85.6177 178.9929 0.9995 80.2915
118.1497 46.4473 0.9997 56.5447
149.8105 144.2425 0.9996 66.6219
57.5137 60.0198 0.9996 58.3396
148.5759 52.1945 0.9996 68.1541
118.1497 46.4473 0.9997 56.5447
6.3739 46.7388 0.9991 107.7154
6.3739 46.7388 0.9991 107.7154
92.6472 91.4933 0.9998 11.2440
118.1497 46.4473 0.9997 56.5447
174.4820 106.2654 0.9996 74.7451
148.5759 52.1945 0.9996 68.1541
92.6472 91.4933 0.9998 11.2440
89.2563 159.2453 0.9996 60.2115
39.7329 17.9399 0.9992 101.8134
148.5759 52.1945 0.9996 68.1541
89.2563 159.2453 0.9996 60.2115
162.7530 60.5971 0.9996 74.0981
174.6445 87.0270 0.9996 75.7634
174.4820 106.2654 0.9996 74.7451
162.7530 60.5971 0.9996 74.0981
39.7329 17.9399 0.9992 101.8134
85.6177 178.9929 0.9995 80.2915
149.8105 144.2425 0.9996 66.6219
118.1497 46.4473 0.9997 56.5447
148.5759 52.1945 0.9996 68.1541
149.8105 144.2425 0.9996 66.6219
149.8105 144.2425 0.9996 66.6219
85.6177 178.9929 0.9995 80.2915
39.7329 17.9399 0.9992 101.8134
39.7329 17.9399 0.9992 101.8134
121.4697 71.5445 0.9997 35.6464
138.7181 92.9601 0.9997 39.3529
138.7181 92.9601 0.9997 39.3529
92.6472 91.4933 0.9998 11.2440
6.3739 46.7388 0.9991 107.7154
89.2563 159.2453 0.9996 60.2115
148.5759 52.1945 0.9996 68.1541
85.6177 178.9929 0.9995 80.2915
174.4820 106.2654 0.9996 74.7451
85.6177 178.9929 0.9995 80.2915
174.6445 87.0270 0.9996 75.7634
89.2563 159.2453 0.9996 60.2115
57.5137 60.0198 0.9996 58.3396
39.7329 17.9399 0.9992 101.8134
57.5137 60.0198 0.9996 58.3396
85.6177 178.9929 0.9995 80.2915
57.5137 60.0198 0.9996 58.3396
89.2563 159.2453 0.9996 60.2115
174.6445 87.0270 0.9996 75.7634
92.6472 91.4933 0.9998 11.2440
118.1497 46.4473 0.9997 56.5447
174.4820 106.2654 0.9996 74.7451
138.7181 92.9601 0.9997 39.3529
149.8105 144.2425 0.9996 66.6219
39.7329 17.9399 0.9992 101.8134
138.7181 92.9601 0.9997 39.3529
174.6445 87.0270 0.9996 75.7634
138.7181 92.9601 0.9997 39.3529
57.5137 60.0198 0.9996 58.3396
138.7181 92.9601 0.9997 39.3529
85.6177 178.9929 0.9995 80.2915
39.7329 17.9399 0.9992 101.8134
118.1497 46.4473 0.9997 56.5447
6.3739 46.7388 0.9991 107.7154
121.4697 71.5445 0.9997 35.6464
118.1497 46.4473 0.9997 56.5447
118.1497 46.4473 0.9997 56.5447
39.7329 17.9399 0.9992 101.8134
85.6177 178.9929 0.9995 80.2915
6.3739 46.7388 0.9991 107.7154
121.4697 71.5445 0.9997 35.6464
89.2563 159.2453 0.9996 60.2115
162.7530 60.5971 0.9996 74.0981
57.5137 60.0198 0.9996 58.3396
89.2563 159.2453 0.9996 60.2115
39.7329 17.9399 0.9992 101.8134
174.4820 106.2654 0.9996 74.7451
174.6445 87.0270 0.9996 75.7634
57.5137 60.0198 0.9996 58.3396
89.2563 159.2453 0.9996 60.2115 ];
i should get like this ( the value should not get repeated )
AllCH=[6.3739 46.7388 0.9991 107.7154
174.6445 87.0270 0.9996 75.7634
148.5759 52.1945 0.9996 68.1541
89.2563 159.2453 0.9996 60.2115
57.5137 60.0198 0.9996 58.3396
92.6472 91.4933 0.9998 11.2440
39.7329 17.9399 0.9992 101.8134
57.5137 60.0198 0.9996 58.3396 ];
To remove duplicate rows from a matrix:
AllCH = unique(AllCH, 'rows'); %you can add 'stable' to preserve the ordering
I'm not sure what your definition of repeated is though, since this returns more rows than your example.
ya i'm getting thank you sir,

Sign in to comment.

More Answers (0)

Categories

Asked:

on 27 Nov 2014

Commented:

on 27 Nov 2014

Community Treasure Hunt

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

Start Hunting!