function [x,y,ytrue]=genData(n,sigma) % [x,y] = genData(n,sigma) % % generate n points between -1 and 1, compute true value of f(x) and % add Gaussian noise with variance sigma^2 % % [x,y,ytrue] = genData(...) also returns the "true" values of y (without % the additive noise). x=unifrnd(-1,1,1,n); ytrue=sin(x); noise = randn(1,n)*sigma; y=ytrue+noise;