Finding position of a multidimensional array given manual value

조회 수: 1 (최근 30일)
IDN
IDN 2021년 12월 19일
댓글: Matt J 2021년 12월 20일
Hello,
I have the following:
[max_val, position] = max(sh(:)); %Gets max value of sh and provides position
[yAxInd,yCxInd,yVxInd] = ind2sub(size(sh),position); % Given position it provides me with the multidemnsional parameters
--------------
Is there any way i can provide the value myself to then get the parameters? Something like this..
[position] = [MyInput]; % User looking for position of a particular value
[yAxInd,yCxInd,yVxInd] = ind2sub(size(sh),position); %Given position it provides me with the multidemnsional parameters
Thanks! Appreciate the help!

채택된 답변

Matt J
Matt J 2021년 12월 19일
편집: Matt J 2021년 12월 19일
Your question is a little unclear to me, but I think you mean this:
[yAxInd,yCxInd,yVxInd] = ind2sub(size(sh),find(sh==value))
  댓글 수: 4
IDN
IDN 2021년 12월 20일
I see, it does work, the only issue i think am having is that there are alot of result matching the value so it creates a matrix 0x1 double and i am not able to see the values...any input? Thanks!
Matt J
Matt J 2021년 12월 20일
It is of course possible that there may be no matches or many. The code has succeeded in either case.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by