Professional Documents
Culture Documents
BTE 4415
y
Dy
D2y
Dny
BTE 4415
dy 2 y 12 dt
y(0) 10
BTE 4415
dy 2 y 12sin 4t dt
y(0) 10
BTE 4415
d y dy 3 2 y 24 2 dt dt y(0) 10 y '(0) 0
>> y = dsolve('D2y + 3*Dy + 2*y = 24', 'y(0)=10', 'Dy(0)=0') y = 12+2*exp(-2*t)-4*exp(-t)
BTE 4415
y(0) 0
y '(0) 10
>> y = dsolve('D2y + 2*Dy + 5*y = 20', 'y(0) = 0', 'Dy(0) = 10') y = 4+3*exp(-t)*sin(2*t)-4*exp(-t)*cos(2*t)
>>ezplot(y, [0 5]}
Dr. Nassereldeen A. Kabashi BTE 4415
BTE 4415
Example 6. Determine the Laplace transform of the function below using MATLAB.
v(t ) 3e
2t
sin 5t 4e
2t
cos5t
BTE 4415
Example 6. Continuation.
>> V = laplace(v) V = 15/((s+2)^2+25)+4*(s+2)/((s+2)^2+25)
BTE 4415
Example 7. Determine the inverse transform of the function below using MATLAB.
>> syms t s
Example 7. Continuation.
>> f = ilaplace(F)
f= 50*exp(-t)-20*exp(-2*t)-30*exp(-t)*cos(2*t)-10*exp(t)*sin(2*t)
BTE 4415
Example 8. Determine the inverse transform of the function below using MATLAB.
10 48 Y ( s) 2 s 2 ( s 2)( s 16)
>> syms t s >> Y = 10/(s+2) + 48/((s+2)*(s^2+16)) Y = 10/(s+2)+48/(s+2)/(s^2+16)
BTE 4415
Example 8. Continuation.
>> y = ilaplace(Y) y = 62/5*exp(-2*t)12/5*cos(16^(1/2)*t)+3/10*16^(1/2)*sin(16^(1/2)*t)
BTE 4415
Optimization
All of these are optimization problems Matlab has several functions to perform optimization
Same problem as with ODE: solver needs to work with YOUR functions Must pass function handle
BTE 4415
Optimization
x0);%Finds f(x)==0 starting from x0 x=fminbnd(@fun, [xL, xR]); %Finds minimum in interval [xL,xR] x=fminsearch(@fun,x0); %Finds minimum starting at x0
f=fun(x);%computes f(x)
BTE 4415
Optimization Toolbox
Some of these functions can make use of gradient information in higher dimensions, gradient tells you which way to go, can speed up procedure
df/dx = 0
Dr. Nassereldeen A. Kabashi BTE 4415
Optimization Toolbox
[x,dx]=fun(x);
if(nargout>1)
dx=
end
x=
BTE 4415
Optimization Options
optimset:
opts=optimest(ParameterName,value); Then
BTE 4415
Summary
dx/dt
(ODE) f (Optimization)
You
pass the name of the function to the solver Solver calls it repeatedly and returns answer
BTE 4415