how can i run this code need help?

1 view (last 30 days)
Akhtar Jan
Akhtar Jan on 9 Mar 2022
Commented: Jan on 10 Mar 2022
%its about Solving PDEs by Asymmetric MQ Collocation the above code is already given in the book which %i have
%pasted below i havn't much experience in MATALAB thats why i shared it here...
%Neumann Boundary Conditions
%The function f is set to f(x, y) = -2(2y3 - 3y2 + 1) + 6(1 - x2)(2y - 1) and Dirichlet boundary conditions
%of u(0, y) = 2y2 - 3y2 + 1 and u(1, y) = 0 are applied as well as Neumann boundary conditions of
%∂u/∂y = 0, along y = 0 and y = 1.
%A shape parameter of ε = 2.5 results in an evaluation matrix to be inverted that has a very high condition %number
%κ(H) ≈ 4.6e19.
clc
Nb = 22; % number of boundary point s
Np = 60; % t o t a l number of c ent e r , i n t e r i o r and boundary
centers = dlmread(centersUnitCircle60.txt ,'_');
x = centers(:,1);y = centers(:,2);
u = 65./(65+(x-0.2).^2+(y+0.1).^2 );% e x ac t s o l u t i o n
f = 130./(65+(x-0.2).^2+(y+0.1).^2 ).^3.*(2.*x-0.4).^2 - ...
260./(65+(x-0.2).^2+(y+0.1).^2).^2+...
130./(65+(x-0.2).^2+(y+0.1).^2).^3.*(2.*y+0.2).^2;
H = zeros (Np,Np ); rx = zeros (Np,Np ); ry = zeros (Np,Np); r = zeros (Np,Np );
f ( 1 :Nb) = u ( 1 :Nb ) ; % Di r i c h l e t Boundary c ond i t i ons
for i =1:Np
for j =1:Np
rx ( i , j ) = x ( i ) -x ( j ) ;
ry ( i , j ) = y ( i ) - y ( j ) ;
r ( i , j ) = sqrt ( rx ( i , j )^2 + ry ( i , j )^2 ) ;
end
end
index = 1 ;
for shape =1.0: -0.01: 0.1;
H( 1 :Nb , : ) = mq( r ( 1 :Nb , : ) , shape ) ; % enf or c e boudary c ond i t i ons
Hxx = mqDerivatives( r (Nb+1:Np , : ) , rx (Nb+1:Np , : ) , shape , 2 ) ; % enf or c e PDE
Hyy = mqDerivatives( r (Nb+1:Np , : ) , ry (Nb+1:Np , : ) , shape , 2 ) ;
H(Nb+1:Np , : ) = Hxx + Hyy ; % e v a l u a t i on matrix
kappa ( index ) = cond(H) ;
warning off
lambda = H\ f ; % expansion c o e f f i c i e n t s v i a Gaussian e l imi na t i on
warning on
B = mq( r , shape ) ; % system matrix
uh = B*lambda ; % approximate s o l u t i o n
e r ( index ) = norm(u?uh , i n f ) ;
sh ( index ) = shape ;
index = index + 1 ;
end
semilogy( sh , er , 'b' ) , xlabel ’ shape parameter ’ , ylabel ’max e r r o r ’
figure , semilogy( sh , kappa ) , xlabel ’ shape parameter ’ , ylabel ’ \kappa (H) ’
  14 Comments
Akhtar Jan
Akhtar Jan on 10 Mar 2022
Edited: Akhtar Jan on 10 Mar 2022
%its about Solving PDEs by Asymmetric MQ Collocation the above code is already given in the book which %i have
%pasted below i havn't much experience in MATALAB thats why i shared it here...
%Neumann Boundary Conditions
%The function f is set to f(x, y) = -2(2y3 - 3y2 + 1) + 6(1 - x2)(2y - 1) and Dirichlet boundary conditions
%of u(0, y) = 2y2 - 3y2 + 1 and u(1, y) = 0 are applied as well as Neumann boundary conditions of
%∂u/∂y = 0, along y = 0 and y = 1.
%A shape parameter of ε = 2.5 results in an evaluation matrix to be inverted that has a very high condition %number
%κ(H) ≈ 4.6e19.
Jan
Jan on 10 Mar 2022
@Walter Roberson: Although the OP does not want to do it, I want to say: Thank you for spending your time for fixing the code.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 9 Mar 2022
The function is called 'linspace', not 'linespace'.
  4 Comments
Akhtar Jan
Akhtar Jan on 10 Mar 2022
%its about Solving PDEs by Asymmetric MQ Collocation the above code is already given in the book which %i have
%pasted below i havn't much experience in MATALAB thats why i shared it here...
%Neumann Boundary Conditions
%The function f is set to f(x, y) = -2(2y3 - 3y2 + 1) + 6(1 - x2)(2y - 1) and Dirichlet boundary conditions
%of u(0, y) = 2y2 - 3y2 + 1 and u(1, y) = 0 are applied as well as Neumann boundary conditions of
%∂u/∂y = 0, along y = 0 and y = 1.
%A shape parameter of ε = 2.5 results in an evaluation matrix to be inverted that has a very high condition %number
%κ(H) ≈ 4.6e19.
Jan
Jan on 10 Mar 2022
Edited: Jan on 10 Mar 2022
@Akhtar Jan: Your code contains to many spaces. Your description contains a lot of % characters. It is a good idea to spend the time to post clean messages, if you want to motivate others to help you.
You have been told already, that statements as "but not.....run" are not useful. Post the error message you see, or even better: read the message and try to fix the specific problem.

Sign in to comment.

Tags

Products


Release

R2015a

Community Treasure Hunt

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

Start Hunting!