How can I use the function?

Hi all,
I was trying to understand this code:
Assuing there are a lot of files named 'Plane'.
So, what does this actually tell? and in order to work, how am I supposed to do? Is it a function that I have to recall from another script?
Files=dir('Plane*.xls');
x1=[1,2,3,4,5,6,7,8,9,10,11,12,13,14];
x2=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16];
for i=1:15
[Re_Plane(i),delRe_Plane(i),alp_Plane(i),Cl_Plane(i),Cd_Plane(i),Cdth_Plane(i),delCl_Plane(i),delCd_Plane(i)]=Airplane(x1(i),x2(i),Files(i).name);
end
Re_Plane=mean(Re_Plane);
delRe_Plane=std(Re_Plane)*3.821;
delCdth_Plane=ones(1,15)*(Cdth_Plane(11)-Cdth_Plane(10))/2;

1 comentario

darova
darova el 11 de Abr. de 2020
Do you have more information?

Respuestas (2)

Cris LaPierre
Cris LaPierre el 11 de Abr. de 2020

0 votos

This code has an indexing error, and as such, won't run.
Where'd you get this code from? Is it supposed to be working?
Image Analyst
Image Analyst el 11 de Abr. de 2020

0 votos

It returns 8 values from the Airplane() function for every file you pass in to it, up to a max of 15 files. And you'd better have exactly 15 files or else you'll get an error. If you want all files regardless of how few or many there are, do this:
for i = 1 : length(Files)

4 comentarios

Sun Kyoo Choi
Sun Kyoo Choi el 12 de Abr. de 2020
Cool, and one more question!
If I am trying to use for loop to obtain 15 different Cd values because I have 15 different E100 files,
EE = dir('/Users/jameschoi/Desktop/ENGR/Air/E100*.xls');
filesE100 = {E100.name};
for i = 1:length(filesE100)
fname = filesE100{i};
data = dlmread(fname,'',1,0);
U_0=data(:,1);
U0=mean(U_0);
deltaU0=std(U_0)*t;
Ls=data(:,5);
Ds=data(:,6);
U=data(:,3);
y=data(:,7);
y=y/100;
y1=11.8; y2=13.8;
dy=y(2)-y(1);
y1=y1/100;
y2=y2/100;
i1=find(y==y1);
i2=find(y==y2);
U1_1=U(i1);
U1_2=U(i2);
U1=(U1_1+U1_2)/2;
m=(U1_2-U1_1)/(y2-y1);
U2=U-m.*y;
U2=U2(i1:i2);
theta=sum(U2/U1-(U2/U1).^2)*dy;
Cd=2*theta/c;
end
%Assuing that I have entered all of the variables, but at the end, it only shows
%single value of Cd. So, I was wondering how I could illustrate 15 different Cd
%Values?
% Should I put like Cd(i) = ..., which did not work..
Image Analyst
Image Analyst el 12 de Abr. de 2020
Why doesn't Cd(i)=2*theta/c; work? Attach two of your workbooks so I can check your loop and code.
Sun Kyoo Choi
Sun Kyoo Choi el 12 de Abr. de 2020
Sun Kyoo Choi
Sun Kyoo Choi el 12 de Abr. de 2020
here as well.

La pregunta está cerrada.

Etiquetas

Preguntada:

el 11 de Abr. de 2020

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by