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!
