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

1 Ansicht (letzte 30 Tage)
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?

Akzeptierte Antwort

Matt J
Matt J am 10 Nov. 2013
Bearbeitet: Matt J am 10 Nov. 2013

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by