How can I which value that be used to calculate a function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Tianze Li
am 14 Mai 2019
Kommentiert: Fangjun Jiang
am 17 Mai 2019
In this casue, I difine a range for x and y, and then calculated the min value of L, but how do i find which x vaule and y value to calculate the min L? Many thanks!!!!!
0 Kommentare
Akzeptierte Antwort
Fangjun Jiang
am 14 Mai 2019
Bearbeitet: Fangjun Jiang
am 14 Mai 2019
You need to run min() twice
A=magic(5);
[MinInCol,RowIndex]=min(A);
[MinValue,ColIndex]=min(MinInCol);
Position=[RowIndex(ColIndex),ColIndex];
or better
[MinValue,Index]=min(A(:));
[Ix,Iy]=ind2sub(size(A),Index)
2 Kommentare
Fangjun Jiang
am 17 Mai 2019
Not clear what you mean. Maybe in your example, you are looking for x(Ix), y(Iy)?
Weitere Antworten (1)
Steven Lord
am 14 Mai 2019
Since you indicate that you're using release R2019a, call min with the 'linear' option and two output arguments. This will give you the linear index of the minimum value, and you can use that index into x and y.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!