Right…I swear this should be my last question on this very boring subject.
I’m getting close to having to hand in a report about this, and it’ll be a lot better if I can write about it working than it failing. So…
I’m trying to take all the stuff I’ve just done, put it together and produce an aerofoil profile section from the four digits.
My code is this…
function[max_cam,maxc_pos,max_thick,yc_c,y_c_t]=asec_NACA(n)
% Date: 22nd April 2006
% Author: Harry Smith
% Takes the argument (n), which is a NACA 4-digit code
% and calculates and plots the aerofoil section profile
section_shape=sprintf('%04d',n);
max_cam=str2num(section_shape(1))./100;
maxc_pos=str2num(section_shape(2)).*1;
max_thick=str2num(section_shape(3:4))./100;
% Takes max_thick and calculates thickness disribution curve, y_c_t
t=max_thick;
counti=0;,inc=0.01;,x_c=0;
for x_c=0:inc:1,
counti=counti+1;
% Thickness distribution equation
y_c_t(counti)=5.*t.*((0.29690.*(x_c.^0.5))-(0.12600.*x_c)-(0.35160.*(x_c^2))+(0.28430.*(x_c.^3))-(0.10150.*(x_c^4)));
end
counti=0;,inc=0.01;
% Takes max_cam and its position and calculates mean camber line
f_c=max_cam;
x1=maxc_pos;
% for 0<=(x/c)<=maximum camber position
for i=0:inc:x1,
counti=counti+1;
yc_c(counti)=(f_c).*(1./(x1.^2)).*(2.*x1.*(i)-(i).^2);
end
counti=0;,inc=0.01;
% for (max camber position)<(x/c)<=1
for i=x1+inc:inc:1,
counti=counti+1;
yc_c(counti)=(f_c)*(1/(1-x1)^2.)*((1-2*x1)+2*x1*(i)-(i)^2);
end
% Creating the x-axis
x_c=0:inc:1;
% Calculating the two halves of the aerofoil section
y_top=((yc_c)+(y_c_t));
y_bot=((yc_c)-(y_c_t));
figure,plot(x_c,y_top,y_bot,'k-'),axis equal;
xlabel('x/c'),ylabel('y/c');
But whenever I run it, I get a
>> asec_NACA(4412)
??? Error using ==> +
Matrix dimensions must agree.
Error in ==> C:\Documents and Settings\Harry\My Documents\Uni Work\MATLAB\Problem Set 1\asec_NACA.m
On line 44 ==> y_top=((yc_c)+(y_c_t));
error. I understand that it’s coming up with a problem adding them because I’ve ended up with two different sizes of matrices somehow.
But I can’t see how I’ve done it, they should be ok to add together (at least I think).
If someone could be kind enough to have a look at this and see why it doesn’t work, I’d be ever so grateful and I’ll put it down to you if I graduate and become successful.
Thank you in advance.