The Daily CLAD

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

Re: Nested For Loop Operation

SercoSteveB
Active Participant

What is the status of Array Out and Array Size Out following execution of the VI?

 

 

 Daily CLAD #24 Nest For Loops.png

 

a)      A 2D array of random numbers 3 columns and 5 rows, A 1D array with data = {5,3}

b)      A 2D array of random numbers 5 columns and 3 rows, A 1D array with data = {5,3}

c)       A 2D array of random numbers 3 columns and 5 rows, A 1D array with data = {3,5}

d)      A 2D array of random numbers 5 columns and 3 rows, A 1D array with data = {3,5}

 

 

 

 

 

Comments
RustyStrings
Member

using the snippet and running it makes it too easy so I will not give the answer

the order the rows and columns are assigned is not obvious, is there an easy way to remember how it is done?

mini09
Active Participant

the answer is B am i rit... I found it with the N terminal value wired @RS is this the easy way to find?

RustyStrings
Member

gnshmrthy

try running the code and see if you still think it is B

mini09
Active Participant

huh i tried RS... got the same result... of 2D of 5x3 and 1D of 5x3

RustyStrings
Member

When I run it I get 3 columns

mini09
Active Participant

this sample output is

.1 .3 .2

.5 .6 .7

.8 .0 .9

.3 .4 .6

.3 .5. .3

here its same as 3 colums u are also right... we specify matrix in the form as Row by Column rit ?

RustyStrings
Member

This is something I will need to try to remember here is something to help me/us

I think I will use PRC as a starting point (Pages,Rows,Columns)

when generating arrays it will happen in the reverse order Columns,Rows, and Pages (starting from the inner most loop)

PRC FP.png

PRC.png

SercoSteveB
Active Participant

I remember it by visualising a single loop with auto-indexing on an output tunnel; it will create an array (displayed as a single column) which I think of as a bunch of rows (depending on the numer of iterations).  Then if I add an additional loop inside the first I know it will add additional elements to each of the rows generated by the outer loop, this gives me my columns.

The array size is slightly more vague (mad ).  As a younger man I did alot of map reading, when working out map grid references you read horizontally and then vertically, which I remember as 'along the corridor (horizontal) and up the stairs (vertical)'.  All I need to remember when applying it to 2D Arrays is that it is backwards; the vertical number comes first (the rows), then the horizontal (the columns).  So I just think of map reading backwards.

It works for me......having written it down I am suprised it does.

DiagSon
Member

I used to have the same problem remembering and so found myself writing a dummy loop each time just to be sure. Note that this technique doesn't work in the CLAD exam!

My current aide memoire is to visualise locating a specific character in a book. The order that you would use would be to define the page first, followed by row and then column. This heirarchy - with most significant first - not only relates to the heirarchy of the loops, but this same sequence also applies to the sequence for the array size.

mini09
Active Participant

@RS how do u define the PRC to initialize, am i wrong with my sample output or the default value of the index enabled is RxC.... why do we need pages in the array ?

@steve: ans comments on my result is it wrong? or should we read it as CxR insted of RxC.

mini09
Active Participant

I cant take the snap of the block diagram and post it can any one help me out, if i snap it i could upload it here in the forum.

RustyStrings
Member

here is a link to how to do snippets:

https://decibel.ni.com/content/docs/DOC-7547

once you have saved the snippet you can use insert image in the toolbar of the comment editor

If you look at the front panel of my post above you will see that P R C (pages,rows,columns) was how the indexes and array lengths were ordered

a 2D array has rows and columns if you add a 3rd dimension it would be pages (this has nothing to do with this particular question, I just added it to my code while I was writing it because I know it was was next step)

when initializing with loops as in the diagram I posted it would go C R P from inner loop towards outer loop

mini09
Active Participant

@RS how did u displayed the PRC in the element part as u displayed? and if i add the another element my array is not wiring with the 2D array?

mini09
Active Participant

Finally i understood the LabVIEW array formation which i`m not aware of as i`m working with them for 6 months...  thaks RS, Steve.

SercoSteveB
Active Participant

Answer: A  Best one yet, thanks to everyone who posted.

ashwinilele
Member

its A

ROSEJ
Member

ya.. its A

SC_8
Member

it is B

crossrulz
Knight of NI


SC_8, why are you posting wrong answers to really old posts?  Especially since the answers have been given.  If you want to participate, go to the new ones that haven't been answered yet.  By answered, I mean by SercoSteveB since he's the one that have been writing these up.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
ersmt444
Member

Image is broken.Please do something regarding this issue.

Thank You !!

NishaV
Member

A