how do I switch values in a random matrix without using witch or any kind of loop?

1 回表示 (過去 30 日間)
ilona
ilona 2013 年 11 月 10 日
コメント済み: ilona 2013 年 11 月 10 日
I need to change this matrix
x = round(0+(4)*rand(20,30)) which contains the values 0,1,2,3,4 to the matrix y - - if - x(i,j)=0 than y(i,j)=5
if x(i,j)=1 than y(i,j)=4
if x(i,j)=2 than y(i,j)=3
if x(i,j)=3 than y(i,j)=2
if x(i,j)=4 than y(i,j)=1
this sould be done without using any kind of loops any ideas?

採用された回答

Matt J
Matt J 2013 年 11 月 10 日
編集済み: Matt J 2013 年 11 月 10 日
  1 件のコメント
ilona
ilona 2013 年 11 月 10 日
omg I think this is actually that simple! thank you so much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by