matlab - Matrix main diagonal change -


i have matrix below: a=

1  2 1  2 

i transform to: b=

1  1 2  2 

i have tried use output of diag(a), don't know how concatenate same output twice.

it looks you're swapping anti-diagonal elements. way instead of using transpose indexing:

a([2 3]) = a([3 2]); 

how above code works can access elements in matrix using column-major linear indices. means traverse matrix top bottom, left right. therefore, want access second row first column index 2, first row second column index 3. have swap 2 values, left-side indices reverse of right-side indices.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -