Filter löschen
Filter löschen

how can I write all for loop outputs in single matrix?

4 Ansichten (letzte 30 Tage)
frwmetric
frwmetric am 19 Mai 2013
Bearbeitet: Lottie Wardman am 6 Okt. 2021
how can I write all for loop results in single matrix?
For example
ans =
-2 -2 -1
-2 -2 1
-2 2 -1
-2 2 1
2 -2 -1
2 -2 1
2 2 -1
2 2 1
ans =
0 0 -3
0 0 3
I want to get a result such as
ans =
-2 -2 -1
-2 -2 1
-2 2 -1
-2 2 1
2 -2 -1
2 -2 1
2 2 -1
2 2 1
0 0 -3
0 0 3

Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 19 Mai 2013
Bearbeitet: Azzi Abdelmalek am 19 Mai 2013
For vertical concatenation
A=[1 2 3;4 5 6;7 8 9]
B=[10 20 30;40 50 60]
out=[A;B]
  5 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 19 Mai 2013
What is the problem with your previous comment?
Lottie Wardman
Lottie Wardman am 6 Okt. 2021
Bearbeitet: Lottie Wardman am 6 Okt. 2021
Hi,
Thought I would jump in as I'm having the same difficultly. The loop produces say 21 results, all labelled 'A'. Vertical concatination would work, but as all outputs are produced at once, it's not possible (or practical) to label each output with an alternative letter.
TIA

Melden Sie sich an, um zu kommentieren.


Andrei Bobrov
Andrei Bobrov am 20 Mai 2013
Try this construct
out = [];
for jj = ...
% here your execution
A = ...
out = [out;A];
end
  1 Kommentar
Lottie Wardman
Lottie Wardman am 6 Okt. 2021
Hi,
Sorry I'm very new to MATLAB, please could you explain a little more? I can't seem to use the above to 'join' all the loop results in a single matrix.
TIA

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Creating and Concatenating Matrices 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!

Translated by