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

1 vue (au cours des 30 derniers jours)
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?

Réponse acceptée

Matt J
Matt J le 10 Nov 2013
Modifié(e) : Matt J le 10 Nov 2013

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by