Singular matrix error when code is running?

3 visualizaciones (últimos 30 días)
Christopher
Christopher el 12 de Jun. de 2013
  • When I run this code I am getting a singular matrix error and all the values of A\alpha show up as NaN. Anyone have any idea how to fix this? I am not sure what is wrong. The code runs the output just shows up as NaN.
b=6; % Wing span
n=7;
% number of sections of wing
Type=2; % Type 1 for elliptical wing type 2 for other
c=1;
theta0=linspace(0,pi,n); % theta values for wing span
y0=-b/2*cos(theta0); % Points along wing
S=b*c; % Wing area
c=transpose(interp1([-b/2,0,b/2],[c,c,c],y0)');
AR=b^2/S; % Aspect Ratio
Vinf=36; rho=0.125; % speed and density of the air
alpha0=0; % alpha_zero_lift (in degrees)
alpha0=alpha0*ones(n,1)/180*pi;
Clalpha=2*pi; % in rad^-1
Clalpha=Clalpha*ones(n,1); % lift gradient of each wing section
alphar=2; % angle of attack of the wing root, in degrees
% (it's the reference angle of the wing)
e=1*ones(n,1); % twist of each wing section, in degrees
% --------------------------------------------------------------------
% END OF THE INPUT SECTION
alpha=(alphar-e)/180*pi
% angle of attack of each section (in degrees)
% I build the system A*An=Anoto of n-2 equation, and my PC solve it!
for i=1:n;
i;
for j=1:n,
j;
A(i,j)=4*b*sin((j)*theta0(i))/Clalpha(i)/c(i)+(j)*sin((j)*theta0(i))/sin(theta0(i));
end;
end;
A\alpha

Respuesta aceptada

Roger Stafford
Roger Stafford el 12 de Jun. de 2013
In your expression for A(i,j) you divide by sin(theta0(i)) which is zero at three places as you have defined it. That will give you NaNs all over the place. Why do you want to make such a division?

Más respuestas (0)

Categorías

Más información sobre Special Functions en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by