Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = [0 rand(1,100)*20 20];
- x = sort(x);
- x = x';
- y = abs(sin(x))+(rand()*5)+2;
- distance = trapz(x,y)
- fit1 = fit(x, y, 'poly7')
- aprox1 = feval(fit1, x);
- cvalues = coeffvalues(fit1);
- cnames = coeffnames(fit1);
- output = formula(fit1);
- for ii=1:1:numel(cvalues)
- cname = cnames{ii};
- cvalue = num2str(cvalues(ii));
- output = strrep(output, cname , cvalue);
- end
- output = strrep(output, '^', '.^')
- fhandle = @(x) (output)
- distance = integral(fhandle, 0, 20)
- plot(x, y, 'r', x, aprox1, 'b')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement