matlab - finding a position in loop can find the highest number but need its position -


i have code made prints out "number" , "value" value order came in obtained loop.

i able highest number "numbers can't find way print out "value" or position in example:

number =       3     5     5     4  value 1 has 3  number  value 2 has 6  number  value 3 has 5  number  value 4 has 4  number   highest =    6 

i want out put say

value 2 has 6 number

it can find 6 using max(number) how can position in loop? , case if have 2 numbers equal in both positions

this code

number len= length(number);  %for aligning , display loop x=1; while x<=len     fprintf('value %x has %d  number \n',x,number(x))     x=x+1; end   highest = max(number) 

try using,

[high, pos] = max(number); 

instead of highest = max(number);

where high largest number , pos value required.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -