how can i run this code need help?
조회 수: 1 (최근 30일)
이전 댓글 표시
%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
Jan
2022년 3월 10일
@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.
답변 (1개)
Image Analyst
2022년 3월 9일
The function is called 'linspace', not 'linespace'.
댓글 수: 4
Jan
2022년 3월 10일
편집: Jan
2022년 3월 10일
@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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Boundary Conditions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!