필터 지우기
필터 지우기

Replacing existing matrix elements with new elements!

조회 수: 1 (최근 30일)
Pandiyaraj Gnanasekar
Pandiyaraj Gnanasekar 2019년 12월 25일
댓글: Pandiyaraj Gnanasekar 2019년 12월 25일
Hello everyone!
I am having a 6x6 matrix of numbers ranging from 0 to 5. I want to replace the matrix elements 0 to 5 as 1 to 6.
[2 0 1 3 5 4;
1 2 4 5 0 3;
2 3 5 0 1 4;
1 0 2 3 4 5;
2 1 4 5 0 3;
1 3 5 0 4 2]
I want to replace (0 as 1), (1 as 2), (2 as 3) and so on up to (5 as 6).
if I use for loop it replace itself again and again and resulting in allocation of single number(6) in all positions. Is there is any better way to replace those values.
Any help is greatly appreciated. Thanks in advance.

채택된 답변

Matt J
Matt J 2019년 12월 25일
yourMatrix=yourMatrix+1;
  댓글 수: 1
Pandiyaraj Gnanasekar
Pandiyaraj Gnanasekar 2019년 12월 25일
Thank you so much for the answer. From this I learnt that overthinking is always dangerous!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by