Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

NAME: bishwa Prakash Prajapati

USN no. : 21BTRCS264


Section: C2IT
EXPERIMENT:6
1.

T0=140; % Initial temperature at t=0


T20=80; % Temperature after t=20 minutes
TR=30; % Room/ Ambient Temperature
tspan=[0 35];
[t,T]=ode45(@Newton_Starbucks,tspan,T0);
fprintf('The temperature of the body after 40 minutes: %f \n', T(end))

The temperature of the body after 40 minutes: 69.730178

plot(t,T,'--b')
xlabel('Time t');
ylabel('Body Temperature T(t)');
grid on

function Tprime=Newton_Starbucks(t,T)
T0=80;
T20=60;
TR=40;

1
k=(1/20)*log((T0-TR)/(T20-TR));
T_ambient=TR;
Tprime=-k*(T-T_ambient);
end

2
2.

clear all
clc
syms x(t)
ode=diff(x,t)==2000*exp(2*t/5);
cond=x(0)==5200;
xsol(t)=dsolve(ode,cond);
n=7;
Population_Size=subs(xsol(t), t,n)

Population_Size =

t=0:n; % Time scale


X=xsol(t);
plot(t,X,'--b')
xlabel('Time');
ylabel('Bacteria Population Size');
grid on

1
3.

f = [-3; -4;]
f = 2×1
-3
-4

A = [ 1 2
3 2];
b = [8; 12;];
lb = zeros(2,1);
%Next, call a linear programming routine.
options = optimset('Display', 'iter');
[x,fval] = linprog(f,A,b,[],[],lb,[],[],options)
LP preprocessing removed 0 inequalities, 0 equalities,
0 variables, and added 0 non-zero elements.

Iter Time Fval Primal Infeas Dual Infeas


0 0.025 0.000000e+00 0.000000e+00 2.010336e+00
2 0.042 -1.800000e+01 0.000000e+00 0.000000e+00

Optimal solution found.


x = 2×1
2.0000
3.0000
fval = -18

2
3

You might also like