stack two matrices depending on a third matrix
- May 3, 2019
- 2 replies
- 2725 views
I have an initial matrix containing "Yes" and "No". This initial Matrix is named A. A can start with a "Yes" or start with a "No" and the times "Yes" and "No" are in the A Matrix should be unlimited.
In A the "Yes" and "No" do always alternate, they never repeat.
Then there are two matrices which are really vectors; B and C.
I want to stack these two vectors which might have the same number of columns or might not. For this case A, B, and C always have one row.
Recap: A is manually input; B and C are also manually input. Matrix D is generated.
Matrix D is the generated Matrix which is going to have one row. For columns it will have the sum of the columns of B and C or simply the number of columns from the A Matrix which should be the same as the sum of columns of B and C.
D’s first element will be the first element of B if A starts with a “Yes”, but it will be the first element of C if A starts with a “No”. Then it will alternate between the elements of B and C.
An example with out a program to generate Matrix D is attached.
I was thinking of a for function with a stack and an if embedded.
Thanks for anyone's help on this.


