creating combinations in the rows of two large multi-dimensional (N-by-M) matrices

1 view (last 30 days)
I have two large multi dimesional matrices and wanted to create the combination scenarios in row of the two matrices that combination should repeat with the number of column times.
Let
x1=2*ones(5,48);x2=3*ones(5,48);
I want to perform the following operation
Y=x1+x2
the above operation can be added directly but that is not desired here,I want to creat scenarios for the combinations in rows of x1&x2,,,,resulting matrix Y will be 25 by 48
How can I do that in matlab?
  6 Comments
madhan ravi
madhan ravi on 7 Jul 2020
Edited: madhan ravi on 7 Jul 2020
Not clear , what happened to 2? State explicitly how Y should look like.
Rik
Rik on 27 Sep 2022
@Samuel Admas There is no way of knowing how this may be useful to a future reader. That is why we are very hesitant to delete threads. Can you explain in longer form why you think this thread should be deleted?

Sign in to comment.

Answers (1)

KSSV
KSSV on 7 Jul 2020
Read about nchoosek, combnk.
combnk will give you indices, and using these indices you can pick the rows.
  3 Comments
KSSV
KSSV on 7 Jul 2020
There would be 10 combinations, when you select 2 out of 5. nchoosek gives the number of combinations and combnk gives the possilbe combinations.
Samuel
Samuel on 7 Jul 2020
Edited: Samuel on 9 Apr 2021
Thanks but sorry,that is not clear to me and not intended to do it like that either

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!