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

조회 수: 1 (최근 30일)
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일

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by