How to make a matrix of values based on values in another matrix
Show older comments
Hi,
I am trying to make a matrix based on the values in the matrix below. The first column of values needs to be negative, while the second column of values remains positive. The '1' in column 1 (and in column 2 if there were any) also needs to be removed entirely.
The placing of the values are also based on what the value initially is. In the second column, value 2 needs to be put in columns 1 and 2. Value 3 needs to be put in columns 3 and 4, so on so forth. The same applies for the first column, except they're negative.
The value '1' however is completely ignored.

The output should look something like this:

The part that I feel makes this task even more impossible is that this has to work 'universally'. Below is another example:
Input: [ 1 3 ; 2 3 ; 2 4 ; 4 1 ; 2 1 ]
Output: [ 0 0 3 3 0 0 ; -2 -2 3 3 0 0 ; -2 -2 0 0 4 4 ; 0 0 0 0 -4 -4 ; -2 -2 0 0 0 0 ]
I look forward to answers regarding this abomination.
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating 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!