cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Translate the entire conversation x

How to write loop inside another loop

YA_10963798
14-Alexandrite

How to write loop inside another loop

Hi there, 

I have a variable with 100 values inside and I want to check every 5 values to find the minimum between them. I need to do that through the entire values ... this means 20 times . I tried to write it this way but not working : 

YA_10963798_0-1765960507471.png

 

YA_10963798_0-1765959984808.png

z , and q are related to each other . q is the resistance at z depth .. 

the results I expect is : the program will check q at each z and will choose the minimum (q , 15MPa) but will do this in intervals 5 values by 5 values . 

 

the sheet can't be attached again . I attached  zip file 

thanks 

Yusra

 

ACCEPTED SOLUTION

Accepted Solutions
Werner_E
25-Diamond I
(To:YA_10963798)

Here are two implementations of how I understood your question.

The first uses the "submatrix" function to get the minimum of the five values, the second uses a nested for-loop.

Werner_E_0-1765984143091.png

Prime 11 sheet attached

 

View solution in original post

7 REPLIES 7
LucMeekes
23-Emerald IV
(To:YA_10963798)

Hi Yusra,

 

Try this:

LucMeekes_0-1765983381872.png

You should be able to call it with:

LucMeekes_1-1765983469479.png

But you'll also need an associated Z array:

LucMeekes_2-1765983536912.png

LucMeekes_3-1765983554729.png

Now you can plot Q versus Z.

 

Success!
Luc

YA_10963798
14-Alexandrite
(To:LucMeekes)

Hi Luc 

in Z array why you used (i-1)*5+3 

Thanks 

LucMeekes
23-Emerald IV
(To:YA_10963798)

I had to reduce the length of array z to that of Q to make array Z. I decided to take the  middle value of each group of 5 z values for that.

 

Success!

Luc

Werner_E
25-Diamond I
(To:YA_10963798)

Here are two implementations of how I understood your question.

The first uses the "submatrix" function to get the minimum of the five values, the second uses a nested for-loop.

Werner_E_0-1765984143091.png

Prime 11 sheet attached

 

YA_10963798
14-Alexandrite
(To:Werner_E)

there is one remark here .. the result should be 100 values not 20 values only..... I wanted to compare one by one in each 5 values 

which means we divide the 100 values to 20 groups in each group 5 values > and then compare each member to 15 and choose the minimum... 

The end results will still be 20 groups but with the minimum values.  

 

Werner_E
25-Diamond I
(To:YA_10963798)

Unfortunately, I cannot identify a comprehensible algorithm in your description. You may need to provide one or, better yet, several concrete examples to clarify the task.
Do you mean that the desired result should consist of groups of five with identical values?

YA_10963798
14-Alexandrite
(To:Werner_E)

Ok thanks anyway . 

Announcements

Top Tags