=COUNTIF($A$1:$A$6,">=" & A1) - 1
copy down
..
This isn't what the OP's MatLab code does. If it were, then If there were no
duplicates,
=COUNTIF($A$1:$A$6,">"&A1)
would be better. If there were duplicates, and if they should be counted, then
why shouldn't A1 itself be counted?
. . . Perhaps this makes more sense for
Matlab folks... but I can't do this in Excel...
a=[6 3 2 7 5 8]
for j=1:5
count=0
for i=j:5
if a(i+1)>a(j)
count=count+1;
end
end
b(j)=count;
end
j = 1, inner loop checks if [3 2 7 5 8] > 6, b(1) = 2
j = 2, inner loop checks if [2 7 5 8] > 3, b(2) = 3
j = 3, inner loop checks if [7 5 8] > 2, b(3) = 3
j = 4, inner loop checks if [5 8] > 7, b(4) = 1
j = 5, inner loop checks if 8 > 5, b(5) = 1
Given *strictly* greater than, in B1 enter the formula
=COUNTIF(A2:A$6,">"&B1)
Fill B1 down into B2:B5. This makes B1:B5 *exactly* the same as your MatLab
array b() if A1:A6 is exactly the same as your MatLab array a().
--
Never attach files.
Snip unnecessary quoted text.
Never multipost (though crossposting is usually OK).
Don't change subject lines because it corrupts Google newsgroup archives.