13 lines
427 B
Matlab
13 lines
427 B
Matlab
% check whether the median returned by mymedian
|
|
% really separates a vector into two halfs
|
|
for i = 1:140 % loop over different length
|
|
for k = 1:10 % try several times
|
|
a = randn(i, 1); % generate some data
|
|
m = mymedian(a); % compute median
|
|
if length(a(a>m)) ~= length(a(a<m)) % check
|
|
disp('error!')
|
|
end
|
|
end
|
|
end
|
|
|