Can you check my file and correct it ?. Thank you

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

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.
Please experiment a bit with the buttons below Answer this question. It is possible to make your test readable.
And beside the code... Typically example data is need to run and understand code
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.
Please spend some time here.
thank you every one , i have problem in this file ....its not run , error in [ col1, col2, col3, col4 ] from NACA2412.data file.
What is the mistake in these codes? Please help me...
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.
ok , now i did.
[col1, col2, col3, col4] = textread('NACA2412.data','%f%f%f%f%*[^\n]','delimiter',' ');
thank you
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?
??? Error using ==> textread at 167 File not found.
Error in ==> Trim at 6 [col1, col2, col3, col4] = textread('NACA2412.data','%f%f%f%f%*[^\n]','delimiter',' ');
This means, that posting the error message only would have been sufficient already.

Sign in to comment.

Answers (1)

Jan
Jan on 19 Dec 2012
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).

Asked:

on 19 Dec 2012

Community Treasure Hunt

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

Start Hunting!