how can i reject numbers or choose numbers within a specified range

1 view (last 30 days)
i have an equation the gives me around 10 numbers as a result
ex.
z=[1 2 3 4 5 6 7 8 9 10]
A= whatever + z
A= 20
A=30
A=40
A=50
A=60
A=70
A=80
A=90
A=100
A=110
i need a function that eleminates any (A) that is not between 30 and 110
i used
Accepted=A( A>30 & A < 110)
  13 Comments
Image Analyst
Image Analyst on 20 Apr 2019
Correct. Values that do not satisfy the condition will not be in the array. Only values that DO satisfy the condition will be.
Walter Roberson
Walter Roberson on 20 Apr 2019
clear,clc,clf
format short
%80000000 tonn/year
%Amount : 1852054.79452055 barrels oil per day (bbl/d of flow rate)
%Equals : 3.41 cubic meters per second (m3/sec / flow rate)
Q=3.254;
%Density of Arabian Light
rough=850;
g=9.81;
Gamma=(rough.*g);
%Elevation Start
Zs=6;
%Length
L=320000;
%kinematic Viscosity
Ks=(0.000045);
Er=(1.*10.^(-8));
viscosity=(1.07*10.^-5);
% material grade X70
strength= 482;
%API 5L
D5L=[12.75*0.0254 14*0.0254 16*0.0254 18*0.0254 20*0.0254 22*0.0254 24*0.0254 26*0.0254 28*0.0254 30*0.0254 32*0.0254 34*0.0254 36*0.0254 38*0.0254 40*0.0254 42*0.0254 44*0.0254 46*0.0254 48*0.0254 52*0.0254 56*0.0254 60*0.0254 64*0.0254 68*0.0254 72*0.0254 76*0.0254 80*0.0254];
V5L=((4.*Q)./(pi.*D5L.^2))
V=V5L(V5L > 1.5 & V5L < 4.5)
DoM=((4.*Q)./(pi.*V)).^(0.5)
DoI=((4.*Q)./(pi.*V)).^(0.5).*39.37
Re=(V.*DoM./viscosity)
Ze=[6 12 15 27 37 45 54 66 74 70 82 93 104 106 112 117 120 127 134 135 129 128 127 132 144 153 168 178 186 191 193 195 194 202 204 210 214 222 226 231 244 250 255 262 268 263 272 276 285 299 307 318 326 334 348 369 347 350 384 385 381 393 398 409 409 406 405 400 392 380 371 362 358 358 376 357 349 334 328 315 306 294 287 277 332 289 266 258 233 211 183 154 137 117 171 143 115 106 96 92 61 73 66 58 57 42 24 23 14 28 23 22 21 22 22 41 51 56 61 86 80 75 65 65 70 82 107 106 103 104 97 103 105 105 114 119 125 129 132 138 144 158 170 192 194 194 205 195 174 167 160 153 160 166 169 161 159 157 149 138 124 120 119 118 119 111 109 107 123 121 110 106 98 96 92 87 83 91 73 69 62 58 63 90 80 91 101 93 90 80 79 77 76 76 75 63 70 66 61 56 54 60 51 49 39 26 27 25 38 48 42 39 37 31 38 42 40 41 42 48 43 43 47 48 31 23 17 15 17 19 20 26 40 40 31 31 32 33 32 38 25 37 40 40 37 32 33 34 32 28 29 32 28 31 32 28 29 30 30 26 29 28 28 30 29 30 31 29 28 28 25 25 26 25 26 24 25 23 26 21 24 24 23 25 29 36 40 33 27 25 22 23 21 21 20 20 20 21 21 19 18 17 15 16 15 17 18 23 36 39 22 32 37 23 8 -4 0 0 0 0 0];
Fo=0.01;
for I=0:1:10^8;
Fn=(1./(-4.*log10((Ks.*DoM)./3.71)+(1.26./(Re.*(Fo).^(0.5))))).^2
E=abs((Fn-Fo)/Fn);
if E<=Er;
Fn=Fn ,break,
end
if E>Er;
Fo=Fn;
end
end
Hloss=((Fn.*L.*Q.^2)./(12.*DoM.^5))
StandardProfile=[6 12 15 27 37 45 54 66 74 70 82 93 104 106 112 117 120 127 134 135 129 128 127 132 144 153 168 178 186 191 193 195 194 202 204 210 214 222 226 231 244 250 255 262 268 263 272 276 285 299 307 318 326 334 348 369 347 350 384 385 381 393 398 409 409 406 405 400 392 380 371 362 358 358 376 357 349 334 328 315 306 294 287 277 332 289 266 258 233 211 183 154 137 117 171 143 115 106 96 92 61 73 66 58 57 42 24 23 14 28 23 22 21 22 22 41 51 56 61 86 80 75 65 65 70 82 107 106 103 104 97 103 105 105 114 119 125 129 132 138 144 158 170 192 194 194 205 195 174 167 160 153 160 166 169 161 159 157 149 138 124 120 119 118 119 111 109 107 123 121 110 106 98 96 92 87 83 91 73 69 62 58 63 90 80 91 101 93 90 80 79 77 76 76 75 63 70 66 61 56 54 60 51 49 39 26 27 25 38 48 42 39 37 31 38 42 40 41 42 48 43 43 47 48 31 23 17 15 17 19 20 26 40 40 31 31 32 33 32 38 25 37 40 40 37 32 33 34 32 28 29 32 28 31 32 28 29 30 30 26 29 28 28 30 29 30 31 29 28 28 25 25 26 25 26 24 25 23 26 21 24 24 23 25 29 36 40 33 27 25 22 23 21 21 20 20 20 21 21 19 18 17 15 16 15 17 18 23 36 39 22 32 37 23 8 -4 0 0 0 0 0];
DesignProfile=StandardProfile+50;
MaxHead=(((90*10.^5)./(rough.*g))+DesignProfile);
M = min( MaxHead );
Accepted = [];
for i=1:length(Hloss);
Hpump=Hloss(i)+(DesignProfile-56);
HpumpDemanded = max(Hpump);
Accepted = [Accepted, HpumpDemanded(HpumpDemanded< M)];
end
At the end, if nothing was in range, then Accepted will still be [], and otherwise it will be a list of all of the HpumpDemanded that are < M.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!