Can you check my file and correct it ?. Thank you
Show older comments
function AE440_Trim_Diagram( ) % -----Trim Diagram % Airfoil data; row vector of values in order
[col1, col2, col3, col4] = textread('NACA2412.data','%f%f%f%f%*[^\n]','delimiter',' '); % this line has problem , it not want to textread this airfoil file.
alpha = [col1].';
C_l = [col2].';
C_d = [col3].';
C_m_w = [col4].';
% Calculate wing force values based on angle of attack
C_z_w = zeros(1,length(alpha));
C_x_w = zeros(1,length(alpha));
for i = 1:length(alpha)
if alpha(i) > 0
C_z_w(i) = C_l(i)*cosd(alpha(i))-C_d(i)*sind(alpha(i));
C_x_w(i) = C_d(i)*cosd(alpha(i))+C_l(i)*sind(alpha(i));
elseif alpha(i) == 0
C_z_w(i) = C_l(i)*cosd(alpha(i));
C_x_w(i) = C_d(i)*cosd(alpha(i));
else alpha(i) < 0;
C_z_w(i) = C_l(i)*cosd(alpha(i))+C_d(i)*sind(alpha(i));
C_x_w(i) = C_d(i)*cosd(alpha(i))-C_l(i)*sind(alpha(i));
end
end
% Calculate tail force values
c_w_mac = 3.115; % wing mean aerodynamic chord (feet)
l_t = 5.906; % horizontal distance of tail AC BEHIND plane CG (feet)
l_wb = -.312; % horizontal distance of wing AC BEHIND plane CG (feet)
C_z_t = (c_w_mac./l_t).*C_m_w - (l_wb./l_t).*C_z_w;
%h_t = -.594; % vertical distance of tail AC BELOW plane CG (feet)
%h_wb = .147; % vertical distance of wing AC BELOW plane CG (feet)
%C_x_t = (c_w_mac./h_t).*C_m_w - (h_wb./h_t).*C_x_w;
C_x_t = 0; % Assume for early models that the tail is parallel with the wing
% Calculate total force values
C_z_total = [C_z_w + C_z_t];
C_x_total = [C_x_w + C_x_t];
% Plot all the values versus angle of attack
figure
plot(alpha,C_z_total,'k-','linewidth',2)
hold on
grid on
plot(alpha,C_x_total,'k--','linewidth',2)
plot(alpha,C_z_w,'r-','linewidth',2)
plot(alpha,C_x_w,'r--','linewidth',2)
plot(alpha,C_z_t,'b-','linewidth',2)
% plot(alpha,C_x_t,'g--','linewidth',2)
plot(alpha,C_m_w,'g-','linewidth',2)
legend('C_ztotal','C_xtotal','C_zw','C_xw','C_zt','C_mw','location','eastoutside')
title('Monoplane Wing Trim Curves')
xlabel('Angle of Attack Alpha (degrees)')
ylabel('Coeffecient Value')
11 Comments
José-Luis
on 19 Dec 2012
Do you seriously expect someone to go through your code if it is presented as the mess above? Please edit your code. Show some effort, it is a good idea to try to use the debugger first and attempt to isolate what the problem is. A simply stated question might attract more answers.
per isakson
on 19 Dec 2012
Please experiment a bit with the buttons below Answer this question. It is possible to make your test readable.
Andreas Goser
on 19 Dec 2012
And beside the code... Typically example data is need to run and understand code
Image Analyst
on 19 Dec 2012
Edited: Image Analyst
on 19 Dec 2012
Supplying example data is best. Sometimes it's possible without it if the error message is supplied, but he didn't even do that. So we don't know what to correct - if it's a syntax error, a logic error, or the output just doesn't look right or in now what was expected. Posting a screenshot of the plot you make would help. http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers. Edit your code. Highlight just the code lines, then click {}Code in the icon above the edit box so that your code will be formatted properly.
shambhu kumar
on 19 Dec 2012
Image Analyst
on 19 Dec 2012
Edited: Image Analyst
on 19 Dec 2012
How can we do that? By the way, like I said, you highlight your code and cick {}Code. You don't double space it (put blank lines in between like you did) - not sure why you did that instead of what I told you.
shambhu kumar
on 19 Dec 2012
Image Analyst
on 19 Dec 2012
Yes but you did it for the first line only, not all of them. And we still can't test your code nor guess at anything because you didn't share the error message or the wrong output. Did you see my two comments above? Or anyone elses?
shambhu kumar
on 19 Dec 2012
Jan
on 19 Dec 2012
This means, that posting the error message only would have been sufficient already.
Answers (1)
Jan
on 19 Dec 2012
0 votes
The error message is clear: "File not found" means, that the file is not found. There is no file called 'NACA2412.data' in the current folder. Either adjust the name, or change the folder with the cd() command, or add the path name to the file (see help fullfile).
Categories
Find more on Axes Transformations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!