필터 지우기
필터 지우기

Lowest value that fulfills a condition

조회 수: 1 (최근 30일)
Diogo Nascimento
Diogo Nascimento 2017년 11월 29일
댓글: Star Strider 2017년 12월 15일
Hello,
I've a script that takes a long time to run due to the small steps I've set up, but i need precision in the calculations so thats why I need the decimal places.
short version script:
T=0;
W=30000;
while T<=W
theta_tip=theta_tip+0.001;
for i=1:100
T1=int((theta_tip/(y/Rmax))...., y, lim_inf, lim_sup);
T2=int(T1,0,2*pi());
T=1/(2*pi)*T2;
end
end
some of the long story:
theta_tip=0; %degrees - angle of atack of blade tip
T=0; %N - Total produced lift
Up=0; %m/s
Rmax=4;
Rmin=0.5;
nbe=5;
ro=0.8;
chord=0.2;
Omega=42;
Cl_alpha=[6.5044 6.6122 6.7820 7.0986 7.5694];
el_size=(Rmax-Rmin)/nbe; %m - element size in meters
lim_inf=Rmin; %integral inferior limit
lim_sup=lim_inf+el_size; %integral superior limit
syms y
tic
while T<=W
theta_tip=theta_tip+0.00001;
for i=1:nbe
if i==1
lim_inf=lim_inf; %#ok<ASGSL>
lim_sup=lim_inf+el_size;
else
lim_inf=lim_inf+el_size;
lim_sup=lim_inf+el_size;
end
T1=int(1/2*ro*chord*Cl_alpha(i)*((theta_tip/(y/Rmax))*(Omega*y)^2-Up*(Omega*y)), y, lim_inf, lim_sup);
T2=int(T1,0,2*pi());
T=1/(2*pi)*T2;
end
end
toc
[Edit- more variables given] i'll be grateful for any help! thanks!
  댓글 수: 3
Diogo Nascimento
Diogo Nascimento 2017년 11월 29일
I understand, I'll read those and submit the remaining code, I thought it was best not to put everything in here, but i'll simplify the variables and put it here! thanks for the help!
Diogo Nascimento
Diogo Nascimento 2017년 11월 29일
편집: Diogo Nascimento 2017년 11월 29일
theta_tip=0; %degrees - angle of atack of blade tip
T=0; %N - Total produced lift
Up=0; %m/s
Rmax=4;
Rmin=0.5;
nbe=5;
ro=0.8;
chord=0.2;
Omega=42;
Cl_alpha=[6.5044 6.6122 6.7820 7.0986 7.5694];
el_size=(Rmax-Rmin)/nbe; %m - element size in meters
lim_inf=Rmin; %integral inferior limit
lim_sup=lim_inf+el_size; %integral superior limit
syms y
tic
while T<=W
theta_tip=theta_tip+0.00001;
for i=1:nbe
if i==1
lim_inf=lim_inf; %#ok<ASGSL>
lim_sup=lim_inf+el_size;
else
lim_inf=lim_inf+el_size;
lim_sup=lim_inf+el_size;
end
T1=int(1/2*ro*chord*Cl_alpha(i)*((theta_tip/(y/Rmax))*(Omega*y)^2-Up*(Omega*y)), y, lim_inf, lim_sup);
T2=int(T1,0,2*pi());
T=1/(2*pi)*T2;
end
end
toc
I think this is all that's necessary!

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2017년 11월 29일
Use numeric integration rather that the Symbolic Math Toolbox.
With your Symbolic Math Toolbox code, when I ran it on my laptop, I got:
Elapsed time is 110.680337 seconds.
Running this loop on my laptop:
tic
while T<=W
theta_tip=theta_tip+0.00001;
for i=1:nbe
if i==1
lim_inf=lim_inf; %#ok<ASGSL>
lim_sup=lim_inf+el_size;
else
lim_inf=lim_inf+el_size;
lim_sup=lim_inf+el_size;
end
T1(i)=integral(@(y) 1/2*ro*chord*Cl_alpha(i)*((theta_tip/(y/Rmax))*(Omega*y)^2-Up*(Omega*y)), lim_inf, lim_sup, 'ArrayValued',1);
T = T1(i);
end
end
toc
I got:
Elapsed time is 4.579191 seconds.
The only difference was in using the anonymous function with integral.
Also, the ‘T2’ and ‘T’ calculations are redundant, since ‘T2’ essentially multiplies ‘T1’ by ‘2*pi’, then ‘T’ divides ‘T2’ by ‘2*pi’. So ‘T’ is simply ‘T1’. I added the subscripts so that now ‘T1’ is saved as a vector for each value of ‘Cl_alpha’.
  댓글 수: 2
Diogo Nascimento
Diogo Nascimento 2017년 12월 15일
that did the trick! thank you!!
Star Strider
Star Strider 2017년 12월 15일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by