ind2sub is not working properly.
이전 댓글 표시
I have the following piece of code where ind2sub is not working properly because when I plot the function PeLRTfusion in 3D, the results are not compatible. I want to find the coordinates of minimum value of PeLRTfusion. Also, when I use the resulted coordinates again in PeLRTfusion, the value of PeLRTfusion is different than the resulted min value from the code.
MuX1=1;
MuX2=2;
SigmaX1=1;
SigmaX2=0.5;
PH1=0.6;
PH0=1-PH1;
const=6;%A constant for how many sigmas away from the mean the program should go.
step=0.1;%To control the accuracy of the results.
Lower=-const*max(SigmaX1,SigmaX2);
Upper=const*max(SigmaX1,SigmaX2)+max(MuX1,MuX2);
LamdaSearchRange=Lower:step:Upper;
%Pe using the LRT fusion rule.
fun=@(Lamda1,Lamda2) PeLRTfusion(PH1,SigmaX1,SigmaX2,MuX1,MuX2,Lamda1,Lamda2);
PeOfLRT=bsxfun(fun,LamdaSearchRange,LamdaSearchRange');
[MinPeOfLRTval, MinIdx] = min(PeOfLRT(:));
MinPeOfLRTval
[MinLamda1Index, MinLamda2Index] = ind2sub(size(PeOfLRT),MinIdx);
MinLamda1=LamdaSearchRange(MinLamda1Index)
MinLamda2=LamdaSearchRange(MinLamda2Index)
Any help is really appreciated. Thank you.
댓글 수: 5
Image Analyst
2017년 8월 16일
Since I can't test it because you forgot to include PeLRTfusion, I gave up trying to help. Include PeLRTfusion if you want people to be able to run your code and fix it.
Hadi Kasasbeh
2017년 8월 16일
편집: Stephen23
2017년 8월 16일
Hadi Kasasbeh
2017년 8월 16일
편집: Stephen23
2017년 8월 16일
ind2sub seems to be working perfectly:
[MinPeOfLRTval, MinIdx] = min(PeOfLRT(:))
MinPeOfLRTval =
-1.6092e+042
MinIdx =
4018
>> val = PeOfLRT(MinLamda1Index,MinLamda2Index)
val =
-1.6092e+042
>> MinPeOfLRTval - val
ans =
0
Hadi Kasasbeh
2017년 8월 16일
편집: Hadi Kasasbeh
2017년 8월 16일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
