필터 지우기
필터 지우기

Unexpected complex coefficients in a matrix

조회 수: 3 (최근 30일)
Enterprixe
Enterprixe 2017년 3월 30일
답변: David Goodmanson 2017년 3월 30일
Hello, im trying to create a panel method for the study of an airfoil. Inside this problem, i have to obtain a matrix by combination of points created which define the panel distributions and their middle points. So the code is:
for n=1:201
x(n)= 1/2-1/2*cos((n-1)*pi/200);
end
for n=1:200
Pc(n)=(x(n)+x(n+1))/2;
end
for i=1:200
for j=1:200
B(i,j)=(-((Pc(i)-x(j+1))/(x(j+1)-x(j)))*log((Pc(i)-x(j+1))/(Pc(i)-x(j)))-1);
end
end
So, in theory, the matrix B should be not complex at all, with its main diagonal full of just '-1' in each tearm, and that main diagonal should be dominant compared to the rest of coefficients of the matrix.

채택된 답변

David Goodmanson
David Goodmanson 2017년 3월 30일
Hello Javier, The only opportunity here to get a complex number is if the argument of the log term is negative. For all the nondiagonal terms of B you are all right, but for i=j the code produces log(-1) and you get an extra i pi/2 on the diagonal.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by