Vous êtes sur la page 1sur 4

Institiute of Space Technology

MatLab
Assignment 03

Name:
M.Tayyab Ahsan
Department:
Materials science and Engineering
Submitted To:
Sir Arhum
Date of submission:
21 Dec, 2015
Q1:

Code:
q=input('Enter the activation energy');
d=input('Enter the diffusivity');
t1=input('Enter the first temperature range');
t2=input('Enter the 2nd temperature range');
inc=input('Enter the increment you want in temperature range')
if t2>900;
disp('warning the calculation is irrespective of crystal structure
changes')
end
r=1.987;
t=t1:inc:t2
a=-q./(r.*t);
d1=d.*exp(a);
plot(t,d1)
xlabel('Temperature')
ylabel('Diffusion coefficient')
title('variation of diffusion coefficient with temperature')
Output:
Q2

Code :
cs=input('Enter the concentration of carbon at surface:');
co=input('Enter the concentration of carbon at bulk:');
t=input('Enter the temperature of the system (kelvins):');
d=input('Enter the value of the diffusion coefficient:');
x=input('Enter the case depth of the material (m):');
time=input('Enter the time for diffusion (s):');
x1=0:0.01:x;
p=x1./(2*sqrt(d*t));
cx=cs-(cs-co).*erf(p);
disp('concentration distance from surface(m)')
for i=1:length(xt)
fprintf('%d %d\n',cx(i),xt(i));
end
prompt=input('Do you want to calculate time for heat treatment? Y or N:
','s')
if prompt=='y'
cs1=input('Enter the concentration of carbon at surface:');
co1=input('Enter the concentration of carbon in material:');
cx1=input('Enter the required concentratoin of carbon in material:');

d1=input('Enter the value of diffusion coefficient:');


x1=input('Enter the case depth of material(m):');

b=(cs1-cx1)/(cs1-co1);
for i=-3:0.01:3
if erf(i)==b
break
end
end

time=((x1/(2*i))^2)/d1;
fprintf('The time required is %ds', 'time')
end
Output:

Vous aimerez peut-être aussi