This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/linearalgebra/exercises/nonlinearcorrelation.m

10 lines
200 B
Matlab

n = 1000;
x = randn(n, 1);
z = randn(n, 1);
y = x.^2 + 0.5*z;
scatter(x, y)
cov([x y])
r = corrcoef([x y])
text(-2, 8, sprintf('r=%.2f', r(1, 2)))
savefigpdf(gcf, 'nonlinearcorrelation.pdf', 15, 10);