untracked m-files
This commit is contained in:
parent
9a3bc4ece2
commit
cfc7fe652f
8
programming/sinusAmplituden.m
Normal file
8
programming/sinusAmplituden.m
Normal 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
|
6
programming/sinusFrequenzen.m
Normal file
6
programming/sinusFrequenzen.m
Normal file
@ -0,0 +1,6 @@
|
||||
frequenzen = [1.0 2.0 4.0];
|
||||
|
||||
for j = 1:length(frequenzen)
|
||||
frequenz = frequenzen(j);
|
||||
sinusAmplituden
|
||||
end
|
6
statistics/do_regression.m
Normal file
6
statistics/do_regression.m
Normal 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
3
statistics/exp_funct.m
Normal 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
3
statistics/lin_funct.m
Normal file
@ -0,0 +1,3 @@
|
||||
function y = lin_funct(a, b, x)
|
||||
|
||||
y = a.*x + b;
|
7
statistics/lserr.m
Normal file
7
statistics/lserr.m
Normal 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
|
10
statistics/lserr_gradient.m
Normal file
10
statistics/lserr_gradient.m
Normal 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
|
||||
|
Reference in New Issue
Block a user