removal of error in matlab code
Show older comments
I have had various errors, read through the guidance on Integral and function handles, but cannot seem to find the solution...Any help or guidance would be very much appreciated.... Here is my code (it requires the Optimization Toolbox):
%Us=;%.1-10
%Ch and Cmb frm the eqn 34 and 47
i=0;
x=zeros(31);
y=zeros(31);
D=.05;
dp=.003;
Cb=.52;
Cs=11;%4.2 7.6 11.7 15.5
Ch=Cs;
alph=.046;
bth=.2;
%((180*acos((2*yb/D)-1)/pi)-((2*yb/D)-1)*(1-((2*yb/D)-1)*sqrt((2*yb/D)-1)));%11
%plot(Us,press_loss)
%Re=rowh*Uh*Dh/muh;
rows=1240;
rowL=1000;%not confirm
s=rows/rowL;
g=9.81;
rowh=rows*Ch+rowL*(1-Ch);
for Us=1:.1:4
i=i+1;
CD=.44;
omega_0=sqrt((4/3)*(((s-1)*dp*g)/CD));
C=.001;%this is wrong
m=2.39;
omega=omega_0*((1-C)^m);%from the eqn 21
i=0;
D=.05;
incr=pi/(2*100);
for gamma=pi/(2*200):pi:incr
Ryb=.5*D-.5*cos(pi*gamma/180);
Ah=.25*D*D*((180/pi)*acos(2*Ryb/D-1)-(2*Ryb/D-1)*sqrt(1-(2*Ryb/D-1)*(2*Ryb/D-1)));
Sh=D*(180*acos((2*Ryb/D)-1)/pi);
Si=D*sqrt(1-(2*Ryb/D-1)*(2*Ryb/D-1));
Dh=4*Ah/(Sh+Si);
A=pi*D*D*.25;
%yb=.04;%wrong next line is for yb
eps=.000000001;
Uh=Us*A/Ah;
muh=rowh*Uh*Dh/500;%from reynolds number put muh
fh=alph*(rowh*Uh*Dh/muh)^bth;
tauh=.5*rowh*Uh*Uh*fh;
Reh=rowh*Uh*Dh/muh;
f=@(z) 1/sqrt(2*z)+.86*log((dp/Dh)/3.7+2.52/(Reh*sqrt(2*z)));
f1=fsolve(f,10e-3);
r=Dh;
Ustar=Uh*sqrt(f1/2);
ep=.052*Ustar*r;%from the eqn 20
thtb=gamma;
func=(D*D/(2*Ah))*exp(-(omega*D/(2*ep))*(sin(x)-sin(gamma)))*(cos(x))^2;
intgr=integral(func,thtb,pi);
if Cs/Cb-intgr<eps
i=i+1;%this will count the number times the loop continue
Rthtb=thtb;
end
end
x(i)=Us;
y(i)=press_loss;
yb=.5*D-.5*cos(pi*Rthtb/180);
RSh=D*(180*acos((2*yb/D)-1)/pi);
RSi=D*sqrt(1-(2*yb/D-1)*(2*yb/D-1));
taui=.5*f1*rowh*Uh*Uh;
press_loss=(-(tauh*RSh)-(taui*RSi))/Ah;
end
%although in previous it is written that Ryb as variable and yb as value of
%exact yb RSh and RSi as value of exact and RSi and RSh as variable
plot(x,y)
Accepted Answer
More Answers (0)
Categories
Find more on Direct Search in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!