Even though the code is lightning fast, the solution is not the proper one, hence this code is useless. See http://i.imgur.com/VNY73l7.png for example output of k = 6 for a naive (and very slow) implementation of the algorithm, and this submission. Obviously the naive is correct, this submission is incorrect.

Nonetheless thanks for the effort! It would be great if you could produce correct code that is still as fast.

28 Nov 2013

boundedline.m
Plot one or more lines with a shaded boundary (can represent error, confidence intervals, etc).
Author: Kelly Kearney

Thanks for this great and simple submission. I have noticed one problem though, it cannot handle NaNs in the data. Matlab's plot() and line() simply ignore NaN values, but patch() does not draw anything when there are NaNs in the data.

To fix this, I added the following around line 313, right before the actual calls to line() and patch():

% remove nans
for k = 1:numel(xp)
naninds = isnan(xp{k}) | isnan(yp{k});
xp{k} = xp{k}(~naninds);
yp{k} = yp{k}(~naninds);
end

Hey. Thank you so much for creating this script. I had some trouble adapting their z-test in MATLAB and this was really a life saver.

However, I wanted to make a comment that in line 48 you introduce an ordering effect that shouldn't be present. One should be able to enter in r1 and r2 in irrelevant orders and get the same result. That's not how it stands now and it may confuse some users of the script and give Type II errors to some ambitious young researchers :).

Anyhow, it's a simple fix with an abs() like this:

z = abs(z1 - z2) * sqrt( (n-3) / (2*(1-rx)*h) ); %abs added in by NR to control for ordering effect

Hey. Thank you so much for creating this script. I had some trouble adapting their z-test in MATLAB and this was really a life saver.
However, I wanted to make a comment that in line 48 you introduce an ordering effect that shouldn't be present. One should be able to enter in r1 and r2 in irrelevant orders and get the same result. That's not how it stands now and it may confuse some users of the script and give Type II errors to some ambitious young researchers :).
Anyhow, it's a simple fix with an abs() like this:
z = abs(z1 - z2) * sqrt( (n-3) / (2*(1-rx)*h) ); %abs added in by NR to control for ordering effect
Once again...thanks!

Comment only