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

% Aadyotya Pandey (1RV22IM002)

% Set diffusion coefficient


c2 = 1;

% Set spatial and temporal steps


h = 1/4;
k = 1/32;

% Set time duration


t_end = 5.0;

% Discretize the spatial domain


x = 0:h:1;
N = length(x);

% Discretize the time domain


t = 0:k:t_end;
M = length(t);

% Initial condition for u(x, 0)


u_0 = 2*x.*(x <= 0.5) + 2*(1 - x).*(x > 0.5);

% Initialize the solution matrix


u = zeros(N, M);

% Apply initial condition


u(:, 1) = u_0;

% Implement boundary conditions at x = 0 and x = 1 for all time steps


u(1, :) = 0;
u(N, :) = 0;

% Discretize the partial differential equation using the finite difference


method
for j = 2:M
for i = 2:N-1
u(i, j) = c2 * k^2 / h^2 * (u(i-1, j) + u(i+1, j) - 2*u(i, j)) + u(i,
j-1);
end
end

% Plot the solution at t = 5.0


plot(x, u(:, end));
xlabel('x');
ylabel('u(x, t)');
title('Solution at t = 5.0');

1
Published with MATLAB® R2023b

2
% Amogh R Naik (1RV22IM007)

% Set diffusion coefficient


c2 = 1;

% Set spatial and temporal steps


h = 1/50;
k = 1/50;

% Set time duration


t_end = 1.00;

% Discretize the spatial domain


x = 0:h:1;
N = length(x);

% Discretize the time domain


t = 0:k:t_end;
M = length(t);

% Initial condition for u(x, 0)


u_0 = 0.5 * x .* (1 - x);

% Initialize the solution matrix


u = zeros(N, M);

% Apply initial condition


u(:, 1) = u_0;

% Implement boundary conditions at x = 0 and x = 1 for all time steps


u(1, :) = 0;
u(N, :) = 0;

% Discretize the partial differential equation using the finite difference


method
for j = 2:M
for i = 2:N-1
u(i, j) = c2 * k^2 / h^2 * (u(i-1, j) + u(i+1, j) - 2*u(i, j)) + u(i,
j-1);
end
end

% Plot the solution at t = 1.00


plot(x, u(:, end));
xlabel('x');
ylabel('u(x, t)');
title('Solution at t = 1.00');

1
Published with MATLAB® R2023b

2
% Shruti Bhendarkar (1RV22IM051)

syms s t;

% Define the Laplace transform


F(s) = (s + 2)/((s^2 - 25)*(s - 2)*(s + 6)) + log((s + 3)/(s - 5));

% Compute the inverse Laplace transform


f(t) = ilaplace(F(s));

% Display the result


disp('Inverse Laplace Transform is:')
disp(f(t));

Inverse Laplace Transform is:


(7*exp(5*t))/330 - (3*exp(-5*t))/70 - exp(2*t)/42 + exp(-6*t)/22 -
exp(-3*t)/t + exp(5*t)/t

Published with MATLAB® R2023b

You might also like