Hi, so I'm trying to get this part of the program running in matlab, and the error, "Attempted to access S_0(2); index out of bounds because numel(S_0)=1." comes up. here's what I have of the code so far. I'm pretty new to matlab, so I don't know all the functions. I'm trying to find the sum of S_0 without using the "sum" function. Please help asap I need this fast!
Here's the code:
% Inputs and Equations that Calculate the Equations for the Coefficient C_l
f = input('Please Enter the First Digit of the NACA Number'); % Input for the Max. Camber
s = input('Please Enter the Second Digit of the NACA Number'); % Input for the Position of Max. Camber
theta = input('Please Enter Angle of Attack in Degrees'); % Angle of Attack in Degrees
M = f/100; % Calculates the Maximum Camber of the Wing
P = s/10; % Calculates the Position of the Maximum Camber of the Wing
x = .5*(1+cos(theta)); % Distance
n = 180/(theta)+1; % Calculates the Number of Rectangles to be Used for the Integral
% Calculation of dy_c/dx for Values of Different x
if x>= 0 && x<=P; dy_c1_dx = (M/P^2)*(2*P-2*x); % This is the Gradient if 0<=X and X<=P
elseif x>=P && x<=1; dy_c2_dx = (M/(1-P)^2)*(2*P-2*x); % This is the Gradient if P<=X and X<=1
endS_0 = 0S_1 = 0for i = 1:n if x>=0 && x<= P; S_0(i) = S_0(i)+(dy_c1_dx); S_1(i) = S_1(i)+(dy_c1_dx)*cos(theta); elseif x> P && x<=1; S_0(i) = S_0(i)+(dy_c2_dx); S_1(i) = S_1(i)+(dy_c2_dx)*cos(theta); end end
Best Answer