Hello, I encountered the following issue: I was defined a vector with a specific length. I want to insert a conditional statement: if value of z<than a specific value then flow to be calculate with a specific formula, else (z>than a specific value) then a flow to be calculate with another formula. Bellow you should view the code:
clc,clf,close all % Calcul GF ca si canal deschis
b=2, % b -latimea conductei rectangulare
zr=116.50; %zr- cota radier
zc=133.10,zg=117.50; %zg- cota ax golire de fund
minval=117.50,z=zr:0.01:zc;A=z(z<minval);t=length(A)B=z(z>=minval)n=0.014; % n- coeficient de rugozitate
i=(116.50-116.40)/54.76; % i - panta hidraulica
if z(z<minval)z=A;A=b*(z-zr).*(z>=zr); %aria sectiunii transversale
C=(1/n)*((b*(z-zr).*(z>=zr))/(b+2*(z-zr).*(z>=zr)))^(1/6);R=((b*(z-zr).*(z>=zr))/(b+2*(z-zr).*(z>=zr)));disp('1')Q=A*C*R^0.5*sqrt(i) elseif z(z>=minval) z=B; % ===================
zz=zg:0.01:zc; zt=zr:0.01:zc; lambda=0.025; % lambda- coef. de rezistenta liniara
L=54.76; % L=72.25; L- lungimea conductei
omega=2*2; % A- aria sectiunii rectangulare a conductei
D=2*sqrt(omega/pi); % D- diametrul efectiv al conductei rectangulare
beta=2.42;s=0.001;b=0.005;alfa=90; Zita_g=beta*(s/b)^4/3*sin(alfa) %Zita_g- pierdere de sarcina gratar
Zita_v=0.10; % Zita_v- pierdere de sarcina vana
Zita_in=0.5; % Zita_in- pierdere de sarcina orif. de intrare
SumZ=Zita_g+Zita_v+Zita_in miu=1/sqrt(1+SumZ+lambda*L/D)kg=miu*omega*sqrt(2*9.81); disp('2')Q=kg.*(z-zg).^0.5 endh=figure;plot(Q,z,'linewidth',3);grid; ;xlabel('Q [mc/s)');ylabel('Cota [mdMN]');title('Cheie limnimetrica golire de fund acumulare Pungesti')disp('test 1')for k=1:length(z) disp(sprintf('%10.2f',z(k),Q(k)))end
Best Answer