Lowest value that fulfills a condition
Show older comments
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 Comments
KL
on 29 Nov 2017
many variables are missing and we cannot guess them!
read this: https://www.mathworks.com/help/matlab/matlab_prog/techniques-for-improving-performance.html
vectorization makes a lot of things simpler.
Diogo Nascimento
on 29 Nov 2017
Diogo Nascimento
on 29 Nov 2017
Edited: Diogo Nascimento
on 29 Nov 2017
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics 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!