how to developed numerical code for collocation method for linear differential equations

69 views (last 30 days)
Anup Negi
Anup Negi on 6 Sep 2020
Commented: Anup Negi on 8 Sep 2020
please sr/ ma'am
our big problem to creat code in MATLAB
i can't undestand , how to write down the diifential equation and boundary condition in matlab
  3 Comments

Sign in to comment.

Accepted Answer

Alan Stevens
Alan Stevens on 8 Sep 2020
Edited: Alan Stevens on 8 Sep 2020
I've just noticed you want to use a collocation method. So you proceed as follows
% For method of collocation choose a functional form for U
% Suppose, for simplicity you choose a simple parabola
% u(z) = a + b*z + c*z^2 (u is potential approximate version of U)
% dudz(z) = b + 2c*z
% d2ud2 = 2*c
% where a, b and c are constants to be determined.
%
% The actual ODE is
% d2Udz2 + A*dUdz + B = 0 where (presumably) you know A and B.
%
% so with your approximate solution this would become
% 2c + A*(b + 2c*z)+ B = 0
% choose a collocation point, z = zcol, say and this becomes
% 2c + A*(b + 2c*zcol)+ B = 0 ...(1)
%
% Assuming you know U on your boundaries, z = eta and z = 1 you also have
% U(eta) = a + b*eta + c*eta^2 ...(2)
% U(1) = a + b + c ...(3)
%
% You now have three equations with which to find a, b and c
% This can be done easily with
% M = [0 A 2+2*A*zcol; 1 eta eta^2; 1 1 1];
% V = [-B; U(eta); U(1)];
% [a; b; c] = M\V;
%
% so your approximate solution is: u(z) = a + b*z + c*z^2
%
% If you want to use more collocattion points you'll need to
% choose a higher order approximate equation.

More Answers (0)

Products


Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by