- #1
GreenLRan
- 61
- 0
I'm having a problem getting my graph labels to work. I get an error saying
"? Index exceeds matrix dimensions.
Error in ==> aeroproject2 at 88
plot(alphaLzero-8:alphaLzero+8,CL(1,1:17)),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')"
can anyone help? thanks, and here is the code.
%%%AEM313 Project 2%%%
%%see in givens%%
prompt = {'Taper Ratio:','Full Span (b):','Wing Twist (degrees):','Zero Lift AOA (degrees):','Sweep Angle (degrees):','M (number of coefficients):'};
title = 'Input';
num_lines = 1;
def = {'.5','5','0','0','22','3'};
answer = inputdlg(prompt,title,num_lines,def);
assignin('base','lamda',answer{1});
assignin('base','b',answer{2});
assignin('base','alpha_GT',answer{3});
assignin('base','alphaLzero',answer{4});
assignin('base','sweep',answer{5});
assignin('base','m',answer{6});
lamda = str2num(lamda)
b = str2num(b)
alpha_GT = str2num(alpha_GT)
alphaLzero = str2num(alphaLzero)
sweep = str2num(sweep)
m = str2num(m)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S=(2*(.5*b*lamda + 2*(.5 * b * .5 *( .5 * (1-lamda)))));
AR= b^2/S;
d_theta = pi /(2*m);
i=1;
theta{i} = pi / 2;
while i <= m
i=i+1;
theta{i} = theta{i-1} - d_theta;
end
for p = 1:m
n = 1;
for j = 1:m
%%%using + in Chord(theta_naught) for right wing
B(p,j) = 2*b/(pi*(1+(1-lamda)*cos(theta{p}))) * sin(n*theta{p}) + n*sin(n*theta{p})/sin(theta{p});
n=n+2;
end
end
for x = 1:m
y=1;
AOA = alphaLzero - 8;
while AOA <= alphaLzero + 8
alpha = AOA + alpha_GT * cos (theta{x});
C(x,y) = (alpha - alphaLzero)*pi/180;
AOA = AOA + 1;
y=y+1;
end
end
A = inv(B(1:m,1:m))*C(1:m,1:17);
CL = pi*AR*A(1,1:17)
AR
for u = 1:17
g=1;
l=1;
while g <= m * 2 - 1
sum=g*A(l,u)^2;
g=g+2;
l=l+1;
end
CDi(u) = pi*AR*sum;
end
aslope = (CL(10)-CL(9));
AoA= alphaLzero-8:alphaLzero+8;
tau = 2*pi/aslope - 2;
v=1;
if (AR > 4) && (sweep < 10)
figure(1)
plot(AoA,CL),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')
end
if (AR < 4) && (sweep < 10)
a=2*pi/(tau^2+3*tau+3)^.5;
for AoA = alphaLzero-8:alphaLzero+8;
CL(v)=a*(AoA - alphaLzero);
v=v+1;
end
figure(1)
plot(alphaLzero-8:alphaLzero+8,CL(1:17)),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')
end
if (AR > 4) && (sweep > 10)
sweep = sweep*pi/180;
a = 2*pi*cos(sweep)/(1+cos(sweep)*(1+tau));
for AoA = alphaLzero-8:alphaLzero+8;
CL(v) = a*(AoA - alphaLzero);
v=v+1;
end
CL(1,1:17)
figure(1)
plot(alphaLzero-8:alphaLzero+8,CL(1,1:17)),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')
end
if (AR < 4) && (sweep > 10)
sweep = sweep*pi/180;
a=2*pi*cos(sweep)/( (1+(cos(sweep)*(1+tau))^2)^.5 + (cos(sweep)*(1+tau)));
for AoA = alphaLzero-8:alphaLzero+8;
CL=a*(AoA - alphaLzero);
v=v+1;
end
figure(1)
plot(alphaLzero-8:alphaLzero+8,CL(1:17)),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')
end
"? Index exceeds matrix dimensions.
Error in ==> aeroproject2 at 88
plot(alphaLzero-8:alphaLzero+8,CL(1,1:17)),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')"
can anyone help? thanks, and here is the code.
%%%AEM313 Project 2%%%
%%see in givens%%
prompt = {'Taper Ratio:','Full Span (b):','Wing Twist (degrees):','Zero Lift AOA (degrees):','Sweep Angle (degrees):','M (number of coefficients):'};
title = 'Input';
num_lines = 1;
def = {'.5','5','0','0','22','3'};
answer = inputdlg(prompt,title,num_lines,def);
assignin('base','lamda',answer{1});
assignin('base','b',answer{2});
assignin('base','alpha_GT',answer{3});
assignin('base','alphaLzero',answer{4});
assignin('base','sweep',answer{5});
assignin('base','m',answer{6});
lamda = str2num(lamda)
b = str2num(b)
alpha_GT = str2num(alpha_GT)
alphaLzero = str2num(alphaLzero)
sweep = str2num(sweep)
m = str2num(m)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
S=(2*(.5*b*lamda + 2*(.5 * b * .5 *( .5 * (1-lamda)))));
AR= b^2/S;
d_theta = pi /(2*m);
i=1;
theta{i} = pi / 2;
while i <= m
i=i+1;
theta{i} = theta{i-1} - d_theta;
end
for p = 1:m
n = 1;
for j = 1:m
%%%using + in Chord(theta_naught) for right wing
B(p,j) = 2*b/(pi*(1+(1-lamda)*cos(theta{p}))) * sin(n*theta{p}) + n*sin(n*theta{p})/sin(theta{p});
n=n+2;
end
end
for x = 1:m
y=1;
AOA = alphaLzero - 8;
while AOA <= alphaLzero + 8
alpha = AOA + alpha_GT * cos (theta{x});
C(x,y) = (alpha - alphaLzero)*pi/180;
AOA = AOA + 1;
y=y+1;
end
end
A = inv(B(1:m,1:m))*C(1:m,1:17);
CL = pi*AR*A(1,1:17)
AR
for u = 1:17
g=1;
l=1;
while g <= m * 2 - 1
sum=g*A(l,u)^2;
g=g+2;
l=l+1;
end
CDi(u) = pi*AR*sum;
end
aslope = (CL(10)-CL(9));
AoA= alphaLzero-8:alphaLzero+8;
tau = 2*pi/aslope - 2;
v=1;
if (AR > 4) && (sweep < 10)
figure(1)
plot(AoA,CL),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')
end
if (AR < 4) && (sweep < 10)
a=2*pi/(tau^2+3*tau+3)^.5;
for AoA = alphaLzero-8:alphaLzero+8;
CL(v)=a*(AoA - alphaLzero);
v=v+1;
end
figure(1)
plot(alphaLzero-8:alphaLzero+8,CL(1:17)),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')
end
if (AR > 4) && (sweep > 10)
sweep = sweep*pi/180;
a = 2*pi*cos(sweep)/(1+cos(sweep)*(1+tau));
for AoA = alphaLzero-8:alphaLzero+8;
CL(v) = a*(AoA - alphaLzero);
v=v+1;
end
CL(1,1:17)
figure(1)
plot(alphaLzero-8:alphaLzero+8,CL(1,1:17)),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')
end
if (AR < 4) && (sweep > 10)
sweep = sweep*pi/180;
a=2*pi*cos(sweep)/( (1+(cos(sweep)*(1+tau))^2)^.5 + (cos(sweep)*(1+tau)));
for AoA = alphaLzero-8:alphaLzero+8;
CL=a*(AoA - alphaLzero);
v=v+1;
end
figure(1)
plot(alphaLzero-8:alphaLzero+8,CL(1:17)),title('CL vs Alpha'),xlabel('Angle of Attack'),ylabel('CL')
end