0% found this document useful (0 votes)
2 views6 pages

Matlab 9

The document presents a MATLAB code for solving a boundary value problem (BVP) related to chemical engineering. It includes the creation of a vector, the use of the bvp4c function for solving the BVP, and the plotting of both numerical and analytical solutions. Additionally, it defines necessary functions for boundary conditions, ordinary differential equations, and initial guesses.

Uploaded by

tsiri9999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Matlab 9

The document presents a MATLAB code for solving a boundary value problem (BVP) related to chemical engineering. It includes the creation of a vector, the use of the bvp4c function for solving the BVP, and the plotting of both numerical and analytical solutions. Additionally, it defines necessary functions for boundary conditions, ordinary differential equations, and initial guesses.

Uploaded by

tsiri9999
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

COMPUTATIONAL

TECHNIQUES FOR
CHEMICAL ENGINEERING Lab 9
Name: T. SIRI CHANDANA
Roll no.: CH23B039
Date:06/11/24
UNSOLVED EXAMPLE
ALGORITHM:
MATLAB CODE:

clear all

%creating the x vector

x = 0:0.1:1;

n = length(x);

solinit = bvpinit(x, @Practicalll_b_InitialGuess);

% Solving the BVP

SOL = bvp4c(@Practicalll_b_ODEFun, @Practicalll_b_BCFun, solinit);

A = SOL.x;

B = SOL.y;

plot(A,B(1,:));

hold on;

%Analytical Solution

y = -(x.^2)/2 + x/2 +1;

plot(x, y,'o');

%Plot formatting

xlabel("x");

ylabel("T(x)");

grid on;

axis([0,1,1,1.2]);

legend('bvp4c','Analytical');

title("Graph representing solution of given BVP");

%Practicalll_b_BCFun

function bc = Practicalll_b_BCFun(Ya,Yb)

bc = [Ya(1) - 1 ; Yb(1) - 1];


end

%Practicalll_b_ODEFun

function dYdX = Practicalll_b_ODEFun(X,Y)

dYdX = [Y(2); -1];

end

%Practicalll_b_InitialGuess

function g = Practicalll_b_InitialGuess(x)

g = [x; x];

end

You might also like