Skip to content

Instantly share code, notes, and snippets.

@d1ff
Created May 4, 2016 10:46
Show Gist options
  • Save d1ff/67efe6d9cd7ae1e7bc5742ec7a24d790 to your computer and use it in GitHub Desktop.
Save d1ff/67efe6d9cd7ae1e7bc5742ec7a24d790 to your computer and use it in GitHub Desktop.
x_val = [1 2 3 4 5 6 7 8 9 10];
n = length(x_val);
x_ = linspace(0, 11, 100);
F_val = zeros(1, length(x));
for j = 1:length(x_)
if x_(j) <= x(1)
F_val(j) = 0;
continue;
end
if x_(j) > x_val(n)
F_val(j) = 1;
continue;
end
for i = 1:n-1
if x_val(i) < x_(j) && x_(j) <= x_val(i+1)
F_val(j) = i / n;
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment