tried
This commit is contained in:
1 parent
e7c5e46421
commit
bb5767833b
5 files changed
+45
No files matched your search
@@ -0,0 +1,13 @@
|
||||
%% Ex. 1: solve for min of x^3 e^-x.
|
||||
options=optimset('Display','Iter','TolFun',1e-8);
|
||||
f1 = @(x) x.^3 .* exp(-x)
|
||||
[x, fv, e, o] = fminbnd(f1, 1, 5, options);
|
||||
disp("its: " + o.iterations)
|
||||
fplot(f1, [1 4])
|
||||
|
||||
%% Ex2: min of xy e(-(x2+y2))
|
||||
|
||||
f2 = @(xy) xy(1).*xy(2).*exp(-(xy(1).^2+xy(2).^2))
|
||||
[x, fv, e, o] = fminsearch(f2, [1 -1], options);
|
||||
disp("its: " + o.iterations)
|
||||
fsurf(@(x, y)f2([x, y]), [-2 2 -2 2])
|
||||
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
function yprime_val = yprime(t,y)
|
||||
% ODE function for Exercise 5
|
||||
yprime_val = t.^2 + y; %
|
||||
end
|
||||
Reference in new issue
Block a user