untracked m-files

This commit is contained in:
Jan Grewe 2015-10-06 09:51:38 +02:00
parent 9a3bc4ece2
commit cfc7fe652f
7 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,8 @@
x = (0:0.01:2*pi);
frequenz = 1.0;
amplituden = [0.25 0.5 0.75 1.0 1.25];
hold on
for i = 1:length(amplituden)
y = sin(frequenz * x) * amplituden(i);
plot(x, y)
end

View File

@ -0,0 +1,6 @@
frequenzen = [1.0 2.0 4.0];
for j = 1:length(frequenzen)
frequenz = frequenzen(j);
sinusAmplituden
end

View File

@ -0,0 +1,6 @@
function parameter = do_regression(x, y, start_parameter)
options = optimoptions('fminunc','GradObj','on');
fun = @exp_funct;
myfunc = @ (p)(lserr(p, x, y, fun));
parameter = fminunc(myfunc, start_parameter, options);

3
statistics/exp_funct.m Normal file
View File

@ -0,0 +1,3 @@
function y = exp_funct(A, tau, t)
y = A .* (1 - exp(-1 * (t./tau)));

3
statistics/lin_funct.m Normal file
View File

@ -0,0 +1,3 @@
function y = lin_funct(a, b, x)
y = a.*x + b;

7
statistics/lserr.m Normal file
View File

@ -0,0 +1,7 @@
function [err, grad] = lserr(p, x, y, fun)
err = sum(y - fun(p(1), p(2), x)).^2;
if nargout > 1
grad = lserr_gradient(p, x, y);
end

View File

@ -0,0 +1,10 @@
function grad = lserr_gradient(param, x, y)
h = 1e-6;
grad = 0*param;
for i = 1:length(param)
paramh = param;
paramh(i) = param(i) + h;
grad(i) = (lserr(paramh,x,y) - lserr(param,x,y))/h;
end