Finding position of a multidimensional array given manual value

1 次查看(过去 30 天)
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