Excluding specific elements from matrix index

Hello. I have a 4x4 matrix where I want to convert the last three elements on row two to 2. How do I exclude specific elements from a matrix row without refering to a element, but rather the element position? Perhaps there are better solutions but im not sure what to make of it.
A(2,find(A(2,:)))=2 turns all elements of row 2 into 2. I cant find a way to exclude row 1 without excluding all elements that have the same value?
Grateful for any help I can get.

 採用された回答

Mischa Kim
Mischa Kim 2014 年 3 月 31 日
編集済み: Mischa Kim 2014 年 3 月 31 日

1 投票

Jonah, how about
A(2,end-2:end) = 2
or, simply,
A(2,2:4) = 2

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2014 年 3 月 31 日

編集済み:

2014 年 3 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by