Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a0=1;
- a1=2;
- N=20;
- x = rand(1,N)*100;
- y0 = a0 + a1*sqrt(x);
- y = y0 + randn(1,N) *0.5;
- X = [ones(N,1), sqrt(x(:))];
- a = (X'*X)^(-1)*X'*y(:),
- xx = 0.1: 0.01:100;
- yy = a(1)+a(2)*sqrt(xx);
- figure(1)
- clf;
- plot(x,y,'bo'); grid on; hold on;
- plot(xx,yy,'r');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement