how to pick element by element

1 回表示 (過去 30 日間)
Offroad Jeep
Offroad Jeep 2016 年 2 月 5 日
編集済み: Stephen23 2016 年 2 月 5 日
A = magic(3)
kindly tell me how i can pick one by one element in same matrix A then do some mathematical operation if it satisfies the condition the element is replaced by new value else it remains the same for example mathematical operation is A + 10, if A+10 is >12 replace other wise remain same as initial value,then second then third..........
thanks
  2 件のコメント
Stephen23
Stephen23 2016 年 2 月 5 日
What operation do you wish to perform?
Offroad Jeep
Offroad Jeep 2016 年 2 月 5 日
I am trying to simulate ferromagnet in which i think this logic will be helpful in flipping the moments

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

回答 (1 件)

Stephen23
Stephen23 2016 年 2 月 5 日
編集済み: Stephen23 2016 年 2 月 5 日
Why not just use logical indexing:
>> A = magic(3)
A =
8 1 6
3 5 7
4 9 2
>> A(A>3) = 0
A =
0 1 0
3 0 0
0 0 2

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by