clearvars

clc

f=@(x)-exp(-5*x)*(9975*sin(100*x)+1000*cos(100*x));

% parameters

nx=91;

L=1;

dx=L/(nx-1);

h=dx;

x=linspace(0,L,nx);

%Boundary conditions

u(1,:)=0;

u(nx,:)=0;

% Multiquadric RBF

beta=20;

a=beta*h;

% Define G(x)

G=zeros(nx,nx+2);

for j=1:nx

for i=1:nx

G(i,j)=sqrt((x(i)-x(j))^2+a^2);

end

end

% Extract the first and last rows of the matrix G

G1=G(1,:);

G2=G(end,:);

G_bar=[G1;G2];

G_a=G(2:end-1,:);

%H

H=zeros(nx,nx);

for i=1:nx

for j=1:nx

H(i,j)=(((x(i)-x(j))*sqrt((x(i)-x(j)).^2+a.^2))/2)+((a.^2)/2)*...

log((x(i)-x(j))+sqrt((x(i)-x(j)).^2+a.^2));

end

end

H_a=[H,ones(nx,1),zeros(nx,1)];

% Plot H

% surf(x, x, H); % 3D plot of H

% xlabel('x');

% ylabel('x');

% zlabel('H');

% title('Plot of H');

% colorbar;

% hold on

%H_bar

H1=zeros(nx,nx);

for i=1:nx

for j=1:nx

H1(i,j)=((sqrt((x(i)-x(j)).^2+a.^2))/6)+((a.^2)/2)*(x(i)-x(j))*....

log((x(i)-x(j))+sqrt((x(i)-x(j)).^2+a.^2))-((a.^2)/2)*...

sqrt((x(i)-x(j)).^2+a.^2);

end

end

% 3D plot of H1

% surf(x, x, H1);

% xlabel('x');

% ylabel('x');

% zlabel('H1');

% title('Plot of H1');

% colorbar;

% Add the new column x and 1

H_bar=[H1,x',ones(size(H,1),1)];

H_inv=pinv(H_bar);

% Conversion matrix

C=[H_bar;G_bar];

C_inv=pinv(C);

%f

f_1=f(0);

f_nx=f(x(nx));

D=[u;f_1;f_nx];

E=C_inv*D;

f_interior=G_a*E;

%A

A=zeros(nx-2,nx-2);

% Populate the tri-diagonal structure of A

for i=2:nx-1

A(i-1,i-1)=-2*exp(-5*x(i))*(9975*sin(100*x(i))+1000*cos(100*x(i)));

if i>2

A(i-1,i-2)=exp(-5*x(i-1))*(9975*sin(100*x(i-1))+1000*cos(100*x(i-1)));

end

if i

More Hassan Raza Bashir's questions See All
Similar questions and discussions