how can i make a function choose?

If i had

DN= [[0.125 0.25 0.375 0.5 0.75 1 1.25 1.5 2 2.5];
OD=[0.405 0.540 0.675 0.84 1.05 1.315 1.66 1.9 2.375 2.875];
t=[0.068 0.088 0.091 0.109 0.113 0.133 0.14 0.145 0.154	0.203];

the above 3 matrix have the same no. of variables. and V varies from 1.5 to 3

ID = sqrt(4.*Q.* 0.000011574074./(pi.*V));
OD = ID + 2.*t;

and i need the OD function choose a the next large number from matrix above. Then align ID , t , DN with it.

11 comentarios

Star Strider
Star Strider el 19 de Abr. de 2018

What are ‘Q’, ‘V’, and ‘v’?

Mahmoud Sami
Mahmoud Sami el 19 de Abr. de 2018
There is one V ( mistake type) Q is input no say 1054
Amjad Green
Amjad Green el 19 de Abr. de 2018
if i understood your question right
try F=[OD ID' t' DN']

‘V varies from 1.5 to 3’

Does this mean, for example:

V = 1.5 : 0.5 : 3;

or something else?

Mahmoud Sami
Mahmoud Sami el 20 de Abr. de 2018
V=1.5:0.1:3; ID, OD, t, DN is the required
Mahmoud Sami
Mahmoud Sami el 20 de Abr. de 2018
@Amjad Green I can't understand the answer
Jan
Jan el 21 de Abr. de 2018
@Mahmoud Sami: I do not understand your question. What is the wanted output for the given example input? What does "align" mean? What is "next large number"?
Mahmoud Sami
Mahmoud Sami el 21 de Abr. de 2018
@Jan The output in that function is ID (Internal pipe diameter ). But ID=OD-2t t and DN is vectors and there must be chosen from it. SO if you get ID no say 10 so OD and t will have numbers but out of vectors so step froward to take the number is the vector more large than that number. I wish i could inform you more simple.
Mahmoud Sami
Mahmoud Sami el 21 de Abr. de 2018
I can try to simplify it. DN, t, & OD is ASME standard, V is velocity Q is discharge. V is recommended to vary from 1.5 to 3 so i must choose the above variables from ASME table that get make V (1.5 to 3) and the relation connect them is ID = sqrt(4.*Q.* 0.000011574074./(pi.*V)); & OD = ID + 2.*t; So if OD get no not in table i must choose the higher one then ID be changed.
Jan
Jan el 21 de Abr. de 2018
@Mahmoud Sami: I do not have any idea of what "ASME standard" is. I do not understand the meaning of the other sentences of your comment also. Again: What is the wanted output for the given example input?
Mahmoud Sami
Mahmoud Sami el 21 de Abr. de 2018
if i have F=[OD ID' t' DN'] as above comment I need 4 variables in that matrix with condition for V (1.5 :3 )

Iniciar sesión para comentar.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Abr. de 2018

1 voto

"and i need the OD function choose a the next large number from matrix above. "
interp1() with the 'next' option.

8 comentarios

Mahmoud Sami
Mahmoud Sami el 25 de Abr. de 2018
Editada: Walter Roberson el 25 de Abr. de 2018
I have Eq.
ID= (4.*Q./(pi.*V)).^0.5;
Q and V is given no.
but need ID to be selected from table, if any other answer can be rejected or choose the nearest large no. of it.
let's say
ID =[0.0134 0.0403 0.0769 0.1023 0.1213 0.1523 0.2031 0.2570 0.3118 0.3436]
and V vary from 1.5 to 3 Q=0.2
Mahmoud Sami
Mahmoud Sami el 25 de Abr. de 2018
I don't know how
bin = discretize( Computed_ID, List_of_Valid_ID, 'IncludedEdge', 'right');
adjusted_ID = List_of_Valid_ID(bin);
Mahmoud Sami
Mahmoud Sami el 27 de Abr. de 2018
Editada: Mahmoud Sami el 27 de Abr. de 2018
That's great it do what i need. Please can you help me in the next part of the question. If we put all listed Value of ID, DN, t, OD in a matrix F=[DN; OD; t; ID] then we get the adjusted ID from the above answer, how can we get the others separately .
Walter Roberson
Walter Roberson el 27 de Abr. de 2018
I don't think I understand the question?
Mahmoud Sami
Mahmoud Sami el 27 de Abr. de 2018
Editada: Walter Roberson el 27 de Abr. de 2018
That is the actual table
DN=[15,20,25,32,40,50,65,80,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000,1050,1100,1150,1200];
OD=[21,26,33,42,48,60,73,89,114,168,219,273,324,355,406,457,508,559,610,660,711,762,813,864,914,965,1016,1067,1118,1168,1219];
t=[2,3,3,4,4,4,5,5,6,7,8,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10];
ID=[17,20,27,34,40,52,63,79,102,154,203,255,304,335,386,437,488,539,590,640,691,742,793,844,894,945,996,1047,1098,1148,1199];
for every single value in ID there is a value in t, DN, OD aligned with it without any mathematical relations so your code get me ID. Is there any method to get the other values
adjusted_OD = OD(bin);
adjusted_DN = DN(bin);
adjusted_t = t(bin);
Mahmoud Sami
Mahmoud Sami el 27 de Abr. de 2018
Thanks alot.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Preguntada:

el 19 de Abr. de 2018

Comentada:

el 27 de Abr. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by