How to get coordinates of largest element in an array?
3 views (last 30 days)
Show older comments
I have an array RHSvec that looks as follows:
RHSvec = [-2.37702213697260e+17 -2.33711662054550e+19 -615937600693473 -4.41919914907522e+19 -3.50291921355524e+20;
-2.40560608664763e+29 -2.16934082274551e+19 -5.73988280489045e+15 -5.33311081810851e+17 -1.17461587901498e+20;
-2.32915727020229e+17 -2.45850745864384e+19 -616589732914132 -6.16155763686288e+15 -4.91512660764408e+19;
-2.32993977385979e+17 -2.14986528565165e+19 -2.94155364006571e+15 -3.65210939697662e+15 -2.12320586283470e+23;
-2.41504694091774e+17 -2.14752641506426e+19 -625473159572963 -3.67525135357355e+17 -4.90376317631114e+19;
-2.33465933952372e+17 -2.15460612285011e+19 -9.81511044091666e+20 -4.19405807636241e+15 -4.90257920973114e+19;
-2.34071058671374e+17 -2.15547532573166e+19 -1.43052472228394e+15 -8.62043004357417e+15 -4.90258050787429e+19]
When I do the following:
[RHSval,kprimeind] = max(RHSvec)
I get
RHSval =
1.0e+19 *
-0.0233 -2.1475 -0.0001 -0.0004 -4.9026
And
kprimeind =
3 5 1 4 6
What I want is
kprimeind =
3 5 1 4 6
And
dprimeind =
1 2 3 4 5
Basically I want coordinates (3,1) (5,2), (1,3), (4,4) (6,1)
How do it get this?
0 Comments
Answers (2)
Stephen23
on 21 Jul 2022
format long G
M = [-2.37702213697260e+17,-2.33711662054550e+19,-615937600693473,-4.41919914907522e+19,-3.50291921355524e+20;-2.40560608664763e+29,-2.16934082274551e+19,-5.73988280489045e+15,-5.33311081810851e+17,-1.17461587901498e+20;-2.32915727020229e+17,-2.45850745864384e+19,-616589732914132,-6.16155763686288e+15,-4.91512660764408e+19;-2.32993977385979e+17,-2.14986528565165e+19,-2.94155364006571e+15,-3.65210939697662e+15,-2.12320586283470e+23;-2.41504694091774e+17,-2.14752641506426e+19,-625473159572963,-3.67525135357355e+17,-4.90376317631114e+19;-2.33465933952372e+17,-2.15460612285011e+19,-9.81511044091666e+20,-4.19405807636241e+15,-4.90257920973114e+19;-2.34071058671374e+17,-2.15547532573166e+19,-1.43052472228394e+15,-8.62043004357417e+15,-4.90258050787429e+19]
[V,X] = max(M,[],1,'linear');
[R,C] = ind2sub(size(M),X)
0 Comments
See Also
Categories
Find more on Plasma Physics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!