MATLAB Week-5
MATLAB
Laplace transforms and limits
Week: 5
LAPLACE TRANSFORM
clc
clear all
syms t s
f=input('Enter the
function in terms of t:');
F=laplace(f)
LAPLACE
TRANSFORM OF UNIT STEP FUNCTION
clearall
clc
symsx
g1=x*(heaviside(x-0)-heaviside(x-1));
g2=(2-x)*(heaviside(x-1)-heaviside(x-2));
f=g1+g2;
F=laplace(f)
xv=linspace(0,2,100);
g1v=subs(g1,x,xv);
g2v=subs(g2,x,xv);
fv=subs(f,x,xv);
subplot(3,1,1)
plot(xv,g1v,'r.')
subplot(3,1,2)
plot(xv,g2v,'r.')
subplot(3,1,3)
plot(xv,fv,'r.')
LAPLACE
TRANSFORM OF PERIODIC FUNCTION
clc
clearall
symsts
T=input('enter the
period of the periodic function : ');
n=input('enter the number
of partitions in one full period : ')
fun = 0*t;
for i=1:n
a(i)=input('enter the
left end point of the ith sub interval
: ');
b(i)=input('enter the
right end point of the ith sub interval
: ');
f(i)=input('enter the
function f(i) of the ith sub interval :
');
fun =
fun+f(i)*(heaviside(t-a(i))-heaviside(t-b(i)));
end
ezplot(fun,[a(1) b(n)])
sum=0;
for i=1:n
sum=sum+int(f(i)*exp(-s*t),t,a(i),b(i))
end
g = (1/(1-exp(-s*T)))*sum
g1=simplify(g)
figure
ezplot(g1,[0 b(n)])
LIMITS AND
CONTINUITY
clear
clc
syms x y m n
f = input('Enter the
function f(x,y): ');
Lp = input('Enter limit
point [x0 y0] as a row vector: ');
x0=Lp(1); y0=Lp(2);
L1=limit(limit(f,x,x0),y,y0);
L1=double(L1);
L2=limit(limit(f,y,y0),x,x0);
L2=double(L2);
disp(['L1 = ', num2str(L1),' L2 = ', num2str(L2)])
if (isnan(L1) || isnan(L2) ||
(L1~=L2))
disp('Limit does not exist.')
return
elseif (L1==L2)
L = input('Enter the value of f at
(x0,y0): '); L=double(L);
if (L1~=L)
disp(['Limit exists for the iterated
paths, but f(x,y) fails to be '...
'continuous at the limit
point.'])
return
else
npaths=input(['Input the
number [of paths through (x0,y0)]. '...
'You may try upto 5: ']);
yp = y0+m*(x-x0)^n;
f = subs(f,y,yp);
for i=1:npaths
val = input(['Input the
value of m and n (as a row vector), '...
'for the trial path
y0+m(x-x0)^n: ']);
m=val(1); n=val(2);
y=subs(yp);
fprintf('The path
considered is y = '); disp(y);
fp=subs(f);
L3 = limit(fp,x,x0); L3=double(L3);
disp(['Limit along
this path is L3 = ',num2str(L3)])
if (isnan(L3)||(L3~=L))
disp(['Limit does
not exist. Function f(x,y) fails to '...
'be continuous at the limit
point.'])
return
end
disp('Function may be continuous at
the limit point.')
end
end
end
Comments
Post a Comment