I have a matrix
A=[1 2 3; 4 6 6;7 7 7]
I want to replace all 6 in the second column with 12 i.e A should be
as follows: A=[1 2 3; 4 12 12;7 7 7]
How to do that easily?

 採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 5 月 5 日

0 投票

A(A==6)=12

3 件のコメント

Mohammad Golam Kibria
Mohammad Golam Kibria 2011 年 5 月 5 日
Actually I need to know replace a particular value of a particular column or row with a specific value. your code replace all values having 6 i.e if
A=[1 2 3; 4 6 6;7 6 7] then output is
A=[1 2 3; 4 12 12;7 12 7]
but output need is:
A=[1 2 3; 4 12 6;7 12 7]
Oleg Komarov
Oleg Komarov 2011 年 5 月 5 日
A(A(:,2)==6,2) = 12;
Mohammad Golam Kibria
Mohammad Golam Kibria 2011 年 5 月 8 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by