Dear all, thanks alot for your responses however this is not what I want. May be I was not so clear in my question so let me explain it agian. What I want is not to find the index of max(C_IA), I will paste below my Input and then state what I want to get: I've originally the following matrix: >> C_IA
C_IA(:,:,1) =
31.3781 + 0.0000i 26.0762 - 0.0000i 29.2083 - 0.0000i
30.1921 - 0.0000i 27.8010 + 0.0000i 26.0254 - 0.0000i
27.9994 - 0.0000i 26.7921 - 0.0000i 27.7583 + 0.0000i
C_IA(:,:,2) =
29.1817 + 0.0000i 28.4916 + 0.0000i 28.6310 + 0.0000i
30.0139 - 0.0000i 29.9155 + 0.0000i 27.0452 - 0.0000i
28.4040 + 0.0000i 27.7000 + 0.0000i 28.3678 + 0.0000i
C_IA(:,:,3) =
26.7694 - 0.0000i 24.7692 - 0.0000i 27.7915 + 0.0000i
26.8899 - 0.0000i 26.0439 - 0.0000i 24.7235 - 0.0000i
26.9859 + 0.0000i 24.8153 + 0.0000i 26.2597 - 0.0000i
Please note that the above output was my result I wanted of a three nested for loops (for K1=1:3 then for K2=1:3 then for K3=1:3)
then I calculated the index of the max of C_IA on three steps in order to know which K1,K2 and K3 values has achived the max(C_IA(:))
[val1 index1] = max(C_IA) [val2 index2] = max(max(C_IA)) [val3 index3] = max(max(max(C_IA)))
when I run the above, I get the following for the first line: >> [val1 index1] = max(C_IA)
val1(:,:,1) =
31.3781 + 0.0000i 27.8010 + 0.0000i 29.2083 - 0.0000i
val1(:,:,2) =
30.0139 - 0.0000i 29.9155 + 0.0000i 28.6310 + 0.0000i
val1(:,:,3) =
26.9859 + 0.0000i 26.0439 - 0.0000i 27.7915 + 0.0000i
index1(:,:,1) =
1 2 1
index1(:,:,2) =
2 2 1
index1(:,:,3) =
3 2 1
and as we have max(C_IA(:)) = 31.3781 then I want to get the first element value of index1 that corresponds to 31.3781 (in this case index1=1
Same for the 2nd step: >> [val2 index2] = max(max(C_IA))
val2(:,:,1) =
31.3781 + 0.0000i
val2(:,:,2) =
30.0139 - 0.0000i
val2(:,:,3) =
27.7915 + 0.0000i
index2(:,:,1) =
1
index2(:,:,2) =
1
index2(:,:,3) =
3
I wanted to get index2 value that corresponds to 31.3781 value (in this case index2=1)
for the last step [val3 index3] = max(max(max(C_IA))) it's clear since what i want is exactly index3 output.
My question is: how can i get index2 value that corresponds to 31.3781 in this case?