LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

HOW TO DRAW THIS VI:NESTED WHILE LOOP

Solved!
Go to solution

How to do this ?

source is a matrix of 360*100 it is a image

 

a=[]
i = 0 while i < len(source): j = 0 while j < len(source[0]): a.append(i,j) j += 1 i += 1

gptshubham595_0-1611248717150.png

Is this correct?

0 Kudos
Message 1 of 16
(345 Views)

Hi gpt,

 


@gptshubham595 wrote:

How to do this ?

Start a text editor and type that text…

 


@gptshubham595 wrote:

source is a matrix of 360*100

 i = 0
    while i < len(source):
        j = 0
        while j < len(source[0]):
            MY_FUCTION()
            j += 1
        i += 1

What exactly is the problem? What have you tried?

I would use 2 autoindexing FOR loops and a subVI named "MY_FUCTION".

 

Why do you need 2 loops to call "MY_FUCTION" 36000 times? From your question that function does NOT depend on i or j…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 2 of 16
(343 Views)
Solution
Accepted by gptshubham595

In LabVIEW we have "auto-indexing" terminals. If you only feed in a 2D array to a for loop, it will run once for each row. If you feed the row into another for loop, it will run once per element, which would be your columns.

Message 3 of 16
(342 Views)

I have edited my question, I want to add a bilateral filter over this image. I am confused regarding two nested while loop, 

 

I know how to implement single while loop 

 

I have edited My_FUNCTION to a array insert, means I have coded this but I want to put it inside a loop

0 Kudos
Message 4 of 16
(334 Views)

Hi gpt,

 


@gptshubham595 wrote:

I am confused regarding two nested while loop, I know how to implement single while loop


Again: use FOR loops with autoindexing inputs!

Place one FOR loop, then place another FOR loop inside the first one to nest them…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 5 of 16
(320 Views)

gptshubham595_0-1611248642977.png

 

 

is this correct showing i and j?

0 Kudos
Message 6 of 16
(315 Views)

 

Did you try to run it to prove it to yourself?

 

No, you need an auto-indexing tunnel on the array wire going into the inner for loop.

 

Also, your text code seems incomplete.  The syntax doesn't show if the i+=1 is part of the inner while loop or outside of that.  By indentation, it seems to be outside the inner while loop.  But I don't see any syntax that shows where the steps of the inner while loop end.

 

Message 7 of 16
(305 Views)

I want a value at that i,j index at every iteration but this return an array 

even inside the array, I want COLSxROWS, not ROWSxCOLS

 

means I tried to test this by myself and with a timer but it is not iterating row with cols but I want to iterate with cols with rows

 

means I want  cols x Rows iteration

1 2 3 4

4 5 6 7

8 9 0 1

 

4

8

 

then

2

5

9

 

 

Yes "i" is outside the inner while loop 

0 Kudos
Message 8 of 16
(298 Views)

Transpose 2D array before you feed it to your loops.

 

Also, when you have auto-indexing tunnels, you do not need, and really shouldn't, put a constant on the N terminal of the For Loop.

0 Kudos
Message 9 of 16
(293 Views)

@RavensFan wrote:

 

Did you try to run it to prove it to yourself?

 

No, you need an auto-indexing tunnel on the array wire going into the inner for loop.

 

Also, your text code seems incomplete.  The syntax doesn't show if the i+=1 is part of the inner while loop or outside of that.  By indentation, it seems to be outside the inner while loop.  But I don't see any syntax that shows where the steps of the inner while loop end.

 


Welcome to Python, where indenting IS your delineation of code blocks.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 16
(283 Views)