Nested for loop in the collections

Hi Experts,
collection1
============
SELECT o.object_id
      BULK COLLECT INTO l_obj_info
        FROM (SELECT     n.node_id, n.object_id
                    FROM nodes n
              START WITH n.node_id = 100
              CONNECT BY PRIOR n.node_id = n.parent_node_id) n
             INNER JOIN
             objects o ON n.object_id = o.object_id
       WHERE o.object_type_id = 285;
collection2
============
SELECT *
      BULK COLLECT INTO l_tab
        FROM ((SELECT     REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL)
                     FROM DUAL
               CONNECT BY REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL) IS NOT NULL));
   END;
collection3
============
SELECT o.object_id
               BULK COLLECT INTO l_fin_tab
                 FROM objects o JOIN ATTRIBUTES att
                      ON o.object_id = att.object_id
                WHERE o.object_id = collection1.object_id
                  --AND att.VALUE = collection2.val;
Please tell me how to implement for loop in the collection3 to get the values from collection1 and collection2.
i have tried in the below way
CREATE OR REPLACE TYPE LIST_OF_ATTRIBUTES_TYPE AS TABLE OF varchar2(4000);
CREATE OR REPLACE TYPE LIST_OF_OBJECT_IDS_TYPE AS TABLE OF number(9);
CREATE OR REPLACE FUNCTION f_get_objects_by_type_id (
   i_object_type_id   IN   NUMBER,
   i_l_text           IN   VARCHAR2,
   i_scope_node_id         NUMBER
   RETURN list_of_object_ids_type
AS
   CURSOR objs_info
   IS
      SELECT o.object_id
        FROM (SELECT     n.node_id, n.object_id
                    FROM nodes n
              START WITH n.node_id = i_scope_node_id
              CONNECT BY PRIOR n.node_id = n.parent_node_id) n
             INNER JOIN
             objects o ON n.object_id = o.object_id
       WHERE o.object_type_id = i_object_type_id;
   l_tab       list_of_attributes_type := list_of_attributes_type ();
   --l_obj_info   list_of_object_ids_type := list_of_object_ids_type ();
   l_fin_tab   list_of_object_ids_type := list_of_object_ids_type ();
BEGIN
   BEGIN
      SELECT *
      BULK COLLECT INTO l_tab
        FROM ((SELECT     trREGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL)
                     FROM DUAL
               CONNECT BY REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL) IS NOT NULL));
   END;
   IF l_tab.COUNT > 0
   THEN
      FOR i IN objs_info
      LOOP
         FOR j IN l_tab.FIRST .. l_tab.LAST
         LOOP
            SELECT o.object_id
            BULK COLLECT INTO l_fin_tab
              FROM objects o JOIN ATTRIBUTES att ON o.object_id =
                                                                 att.object_id
             WHERE
                            att.VALUE = l_tab (j) and o.object_id =objs_info(i);
         END LOOP;
      END LOOP;
   END IF;
   RETURN l_fin_tab;
END f_get_objects_by_type_id;

Why are you wanting to do this?
It looks like you are trying to implement SQL joins in PL code.  Not only is that using up expensive PGA memory by storing the data in collections, but doing such retrieval of data to try and join it in PL loops, is never going to be as fast as just joining the SQL queries using SQL itself.
Post some example data and your database version, with an example of what the output should look like from that example data.
Re: 2. How do I ask a question on the forums?

Similar Messages

  • I'm doing a scan around a line by sampling data 360 degrees for every value of z(z is the position on the line). So, that mean I have a double for-loop where I collect the data. The problem comes when I try to plot the data. How should I do?

    I'm doing a scan around a line by sampling data 360 degrees for every value of z(z is the position on the line). So, that mean I have a double for-loop where I collect the data. The problem comes when I try to plot the data. How should I do?

    Jonas,
    I think what you want is a 3D plot of a cylinder. I have attached an example using a parametric 3D plot.
    You will probably want to duplicate the points for the first theta value to close the cylinder. I'm not sure what properties of the graph can be manipulated to make it easier to see.
    Bruce
    Bruce Ammons
    Ammons Engineering
    Attachments:
    Cylinder_Plot_3D.vi ‏76 KB

  • Issues with nested for loops - saving images from a camera

    Hi all,
    I've written a vi. to capture a specific number of images ('Image No') and save these images, outputted to a folder of my choice.  Each image is identified sequentially.  However, I wish to do a number of iterations ('Run') of this capture sequence, such that the filename of each image would be 'Filename (Run)_(Image No).png', e.g. run 5, image 10 would be 'Filename 5_10.png'.  I have tried a nested for loop for this but I receive an error 'Asynchronous I/O operation in progress' (I've attached a printscreen).
    Can anyone assist me in solving this problem? I preiously posted this in machine Vision but got no response (http://forums.ni.com/t5/Machine-Vision/Capturing-image-sequences-issues-with-nested-for-loops/m-p/19...).  Please find attached my vi.
    Kindest regards and thanks,
    Miika
    Solved!
    Go to Solution.
    Attachments:
    Labview problem.jpg ‏3841 KB
    Image sequence save to file.vi ‏48 KB

    Miika,
    the problem is not the filenam, but the name of the folder (AHHHHH!). You try to create the same folder in the outer for loop over and over again.... (it is the error message above the '======', not below )
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Nested for loop in Xquery

    hi all,
    I need to implement nested for loop in Xquery, but not able to do. Please help.
    Thanks in advance..
    Rajan

    Nested for loops are simple in Xquery. Here is a very basic example:
    Input:
    <root>
    <FirstLevel>
         <SecondLevel>
              <Value>1</Value>
         </SecondLevel>
         <SecondLevel>
              <Value>2</Value>
         </SecondLevel>
         <SecondLevel>
              <Value>3</Value>
         </SecondLevel>
    </FirstLevel>
    <FirstLevel>
         <SecondLevel>
              <Value>4</Value>
         </SecondLevel>
         <SecondLevel>
              <Value>5</Value>
         </SecondLevel>
         <SecondLevel>
              <Value>6</Value>
         </SecondLevel>
    </FirstLevel>
    </root>XQuery:
    declare namespace ns0 = "http://temp.uri/OTM";
    declare function ns0:NestedForLoop($input as element(*))    as element(*)
         <ns0:Output>
              for $firstLevel in $input/FirstLevel
              for $secondLevel in $firstLevel/SecondLevel
                    return
                  <element>{ $secondLevel/Value/text() }</element>
         </ns0:Output>
    declare variable $input aselement(*) external;
    ns0:NestedForLoop($input)Output:
    <otm:Output       xmlns:otm="http://temp.uri/OTM">
         <element>1</element>
         <element>2</element>
         <element>3</element>
         <element>4</element>
         <element>5</element>
         <element>6</element>
    </otm:Output>Of course, this case is very simple and usually you wont even loop for this you can use a simple XPath like $input/FirstLevel/SecondLevel/Value/text() to achieve the above result. So, If you are having problems in a specific case of nested for loops, please post the input and output here and we can help out.

  • Nested For Loop Trouble?

    Ok I need to have a nested for loop that asks a user to enter in a int number from 1-50. Whatever the number is, lets say 4 I need the program to count up asterisk and count down asterisks, like this.
    This is my code:
    import java.io.*;
    public class Stars {
         static int n;
         static private InputStreamReader in = new InputStreamReader(System.in);
         static private BufferedReader br = new BufferedReader(in);
         public static void main(String[] Args)throws IOException
              System.out.println("Please enter in a number to see display: ");
              String num = br.readLine();
              n=Integer.parseInt(num);
              for(int i=1;i<=n;i++)
                   for(int j=1;j<=i;j++)
                        System.out.print("*");
                   for(int j=1;j<=i;j--)
                        System.out.print("*");
                   System.out.println();
    Can someone tell me what I am doing wrong so I can figure out my mistake(s).

    Ok, well I know that the loop relies on the number entered in by the user. So if i pick 3 the three enter in the loop and counts up in a for loop and for every number it counts up to the three it does a print("*"); Now what I am getting confused about is where the other for loop comes into play. I know that I need to start from the number I have which is 3, so I need to have one less than that and then count down. The thing is that i'm not sure where or how the second for loop gets implemented into the code. Does it get nested with the first loop like this:
    for(int i=1;i<=n;i++)
                   for(int j=1;j<=i;j++)
                            for(int j=n-1;j>=i;j--)
                        System.out.print("*");
                   System.out.println();
              }Or is the second for loop on its own like this:
    for(int i=1;i<=n;i++)
                   for(int j=1;j<=i;j++)
                        System.out.print("*");
                   for(int j=n-1;j>=i;j--)
                        System.out.print("*");
                   System.out.println();
              }If someone can help me understand, for this is my first time with nested for loops.

  • Interrupting Nested For Loops/Sequences

    I have a lagre program consisting of nested for loops and case statements calibrating an array of patch antennas. The entire process of which will take about 15 hours. During this time, I want to have two things happen.
    Every 20 minuites or so, I want the process to stop what it's doing, follow certain commands for the measurement equipment to recalibrate itself, and then go back to what it was doing.
    I also want to protect it against unpredicted and predicted crashes. If the system needs to stop for whatever reason, I would like to be able to pick up the process where it left off. A sort of checkpoint system, where, when it passes a checkpoint, if it needs to be restarted, I can tell it to start from the last checkpoint it passed.
    Anyone had any experiece with these types of problems?

    jaysmall wrote:
    I also want to protect it against unpredicted and predicted crashes. If the system needs to stop for whatever reason, I would like to be able to pick up the process where it left off. A sort of checkpoint system, where, when it passes a checkpoint, if it needs to be restarted, I can tell it to start from the last checkpoint it passed.
    Could you open and append parameters to a file? Every time you restart execution of the vi after crashes you can look through the contents of the file to determine the last operation that was successful and continue with the last know good settings.  -SS

  • Multiplication Table with Two Nested For Loops

    I am trying to code a multiplication table in which the user enters the number of rows between 2 and 10 and enters the number of columns from 2 to 10. This must be in nested for loop format somewhat like this:
    rows has been assigned the input variable for rows and columns is the name for input value for columns
    for (int i = 1; i <=rows; i++)
    for (int j = 1; j <=columns; j++)
    i * j
    i can't figure out how to get it to print out in table format or if the calculation coding is correct. can anyone help me please?
    it should look like this for rows is 4 and columns is 7
    1 2 3 4 5 6 7
    2 4 6 8 10 12 14
    3 6 9 12 15 18 21
    4 8 12 16 20 24 28
    Edited by: hatecodingsomuch on Feb 22, 2009 8:15 PM

    hatecodingsomuch wrote:
    I refuse to ask for help from people who are acting like they are all-knowing and unwilling to help someone, considering I am asking for help...to learn. Obviously I am not understanding java very well and I don't need to be ridiculed like this from members who are supposed to help "NEW TO JAVA" individuals. Get off your high horse or get off the website. I will never use this again.Good luck with that.
    You do seem to be yet another "do my homework for me" type of flunkie. I predict you'll soon have an epiphany that software development really isn't for you.
    I hope you know how to say "Do you want fries with that, sir?" better than the next guy so you can edge him out.

  • Nested for loops

    Sorry to bother you all, but I have a small problem with my java homework.
    I have to make a nested for loop to produce the following output:
    00
    10 11
    20 21 22
    30 31 32 33
    (only goes from 0 to 3)
    Now, all I have managed to do are two simple loops, one with increment 10 and the other with increment just ++.
    Could you help me?

    Think through this logically. You need two loops. You need this output:
    00
    10 11
    20 21 22
    30 31 32 33
    Each number above has two digits (two digits, two loops...not a coincidence). So you need one loop to control the first digit, and another loop to control the second digit. Look at the values for the first digit: 0,1,2,3. Those are your first loop values. Now, each time the first loop has a value, your second loop goes through all of its values. Here's the values you need:
    First iteration:
    loop index 1: 0
    loop index 2: 0
    Second iteration:
    loop index 1: 1
    loop index 2: 0,1
    Third Iteration:
    loop index 1: 2
    loop index 2: 0,1,2
    Fourth Iteration:
    loop index 1: 3
    loop index 2: 0,1,2,3
    Notice the pattern for loop 2? Look at the starting value for each iteration, and notice the ending value. That gives you your loop constraints.

  • Nested for loops error

    Hi all Community members,, I am facing problem with pulling attributes from a xml which I have created. I am using nested for loop. Please kindly help me out to solve this problem....
    Thanks in advance...
    Below is the code & xml ...
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.*;
    import flash.net.*;
    var myXML:XML;
    var voiceOver:String;
    var startOffset:Number;
    var slideData:Array;
    var id_cont_array:Array = new Array();
    var id_textfield_array:Array = new Array();
    var id_image_array:Array = new Array();
    var myXML_Container_Length:Number;
    var myXML_textField_Length:Number;
    var myXML_images_Length:Number;
    var loader:URLLoader = new URLLoader();
    loader.load(new URLRequest("dynamic.xml"));
    loader.addEventListener(Event.COMPLETE,processXML);
    function processXML(e:Event):void
    slideData=new Array();
    myXML = new XML(loader.data);
    loader.removeEventListener(Event.COMPLETE, processXML);
    loader.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
    myXML = new XML(e.target.data);
    voiceOver = myXML. @ voice_over;
    startOffset = myXML. @ start_offset;
    for (var i : uint = 0; i<myXML.*.length(); i++)
      //trace(myXML + "slide");
    //myXML_List = myXML.children();
    myXML_Container_Length = myXML.children().length();
    //trace(myXML_Container_Length+ "==myXML_Container_Length")
    //myXML_textField_Length = myXML.containerss[0].children().length();
    //myXML_images_Length = myXML.children().length();
    //trace(myXML.child("containerss")[3]. @ id.toXMLString()+ "==myXML.containerss[0]. @ id;");
    //trace(myXML.containerss[0].textfield[0]. @ id+ "==myXML.slide.containerss[0]. @ id");
    //trace(myXML.containerss[0].textfield[1]. @ id+ "==myXML.slide.containerss[1]. @ id");
    //trace(myXML.containerss[3].image[0]. @ id + "==image[0]");
    //trace(myXML.containerss[0].children() + "==myXML.containerss[0].children()");
    for (var j:Number=0; j<=myXML_Container_Length; j++)
      id_cont_array.push(myXML.containerss[j]. @ id);
      //trace(myXML.containerss[j].children().length() + "==j");
      myXML_textField_Length = myXML.containerss[j].children().length();
      trace(myXML_textField_Length + "==myXML_textField_Length");
      for (var k:Number=0; k<=myXML_textField_Length-1; k++)
       id_textfield_array.push(myXML.containerss[j].textfield[k]. @ id);
       //id_image_array.push(myXML.containerss[k].image[j]. @ id);
       trace(id_textfield_array[k] + "==id_textfield_array[k]==" + k + "---j==" + j);
       //trace(id_image_array[k] + "==id_image_array");
      //trace(id_textfield_array[j]+"==id_cont_array[j]");
    //trace(myXML_List.length() + "===myXML_List");
    function loadError(e:IOErrorEvent):void
    trace("loadError");
    /// XML is as given below..
    <slide orientation="VERTICAL" voice_over="Slide1.mp3" start_offset="0" margin="">
    <containerss id="0" orientation="HORIZONTAL" padding="10" margin="10" x="10" y="160" width="200" height="150">
      <textfield id="Text1" text="textfieldText1" padding="10" margin="10"  x="10" y="160"/>
      <image id="img1" text="" padding="10" margin="10" x="10" y="160"/>
      <textfield id="Text2" text="textfieldText2" padding="10" margin="10" x="10" y="160"/>
    </containerss>
    <containerss id="1" orientation="HORIZONTAL" padding="10" margin="10" width="200" height="200" x="10" y="160">
      <textfield id="Text3" text="textfieldText3" padding="10" margin="10" x="10" y="160"/>
      <image id="img2" text="" padding="10" margin="10" x="10" y="160"/>
    </containerss>
    <containerss id="2" orientation="VERTICAL" padding="10" margin="10" width="200" height="150" x="10" y="160">
      <textfield id="Text5" text="textfieldText5" padding="10" margin="10" width="200" height="150" x="10" y="160"/>
      <image id="img3" text="" padding="10" margin="10" x="10" y="160"/>
      <textfield id="Text6" text="textfieldText6" padding="10" margin="10" x="10" y="160"/>
    </containerss>
    <containerss id="4" orientation="VERTICAL" padding="10" margin="10" width="200" height="150" x="10" y="160">
      <textfield id="Text7" text="textfieldText7" padding="10" margin="10" width="200" height="150" x="10" y="160"/>
      <image id="img4" text="" padding="10" margin="10" x="10" y="160"/>
      <textfield id="Text8" text="textfieldText8" padding="10" margin="10" width="200" height="150" x="10" y="160"/>
    </containerss>
    </slide>

    Parsing is totally wrong. You function processXML() should be like that:
    function processXML(e:Event):void
              slideData = new Array();
              loader.removeEventListener(Event.COMPLETE, processXML);
              loader.removeEventListener(IOErrorEvent.IO_ERROR, loadError);
              myXML = new XML(e.target.data);
              voiceOver = myXML.@voice_over;
              startOffset = myXML.@start_offset;
              myXML_Container_Length = myXML.children().length();
              var node:XMLList;
              for (var j:Number = 0; j <= myXML_Container_Length - 1; j++)
                        id_cont_array.push(myXML.containerss[j].@id);
                        node = myXML.containerss[j].children();
                        myXML_textField_Length = node.length();
                        for (var k:Number = 0; k <= myXML_textField_Length - 1; k++)
                                  switch (node[k].name().toString())
                                            case "textfield":
                                                      trace(node[k].@id);
                                                      id_textfield_array.push(node[k].@id);
                                                      break;
                                            case "image":
                                                      id_image_array.push(node.@id);
                                                      break;

  • Capturing image sequences - issues with nested for loops

    Hi all,
    I've written a vi. to capture a specific number of images ('Image No') and save these images, outputted to a folder of my choice.  Each image is identified sequentially.  However, I wish to do a number of iterations ('Run') of this capture sequence, such that the filename of each image would be 'Filename (Run)_(Image No).png', e.g. run 5, image 10 would be 'Filename 5_10.png'.  I have tried a nested for loop for this but I receive an error 'Asynchronous I/O operation in progress' (I've attached a printscreen).
    Can anyone assist me in solving this problem?  Please find attached my vi.
    Kindest regards and thanks,
    Miika
    Solved!
    Go to Solution.
    Attachments:
    Image sequence save to file.vi ‏48 KB
    Labview problem.jpg ‏3841 KB

    Hi,
    You cannot create a folder if this one is already existing.
    Just check that the folder exists before creating it.
    Regards

  • I need to take elements from within 2 nested for loops and place them in an array at the specific row and column that I need.

    I have tried intializing an array and replacing elements by specifying a particular row, and column, but in the end I get an array with only one element replaced, and I suspect that it is because as the for loops are running through their iterations each time the array is re-initializing. I have a simple vi that I will post below, it is not the exact situation that I have but is a good place for me to get some understanding. I have the row and column indexes being driven by the inner and outer loop iterations, which gives me the pattern I need. I am using the inner iterations as array elements. How do I set this up so that it works and d
    oes keep re-initializing my array.
    Attachments:
    Untitled.vi ‏26 KB

    I have fixed a number of things in your vi.
    You were right in thinking that the array was continuously re-initialized. To avoid this, use a shift register (right-click the loop border), which will pass the updated array into the next iteration.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    your_vi.vi.zip ‏13 KB

  • Which is better??? for loop or bulk collect

    declare
    cursor test is
    select * from employees;
    begin
    open test;
    loop
    exit when test%notfound;
    fetch test into myvar_a(i); CASE A
    i:=i+1;
    end loop;
    close test;
    open test;
    fetch test bulk collect into myvar_b; CASE B
    close test;
    end;
    Which case is better?? A or B?
    Edited by: Kakashi on May 31, 2009 12:54 AM

    Depends on the meaning of better.
    Generally case B should be faster although a bit more elaborate code is required.
    But there may be exceptions. I think I read somewhere (I'm home now and I cannot find it at the moment) that in 10g (or 11g - not sure) 100 rows at a time are pre-fetched behind scenes even when you use case A. So using case B with a low limit could well be slower.
    If I can express an additional opinion case F(irst) is nearly always the best i.e. plain SQL (no loops at all). I'm aware that sometimes it cannot be used, but should be the first approach to be tried.
    Regards
    Etbin
    FOUND: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:213366500346264333
    CONTAINS
    Hey Tom, love the site. I noticed in your first fetch, which was in the first for loop that did an unconditional exit:
    2 for x in ( select rownum r, t1.* from big_table.big_table t1 )
    3 loop
    4 exit;
    5 end loop;
    In looking at the TKPROF output for that query, it shows the number of rows being fetched as 100. Does that prove / demonstrate the bulk collecting optimization that Oracle added in 10g, where it implicitly and automatically does a bulk collect of limit 100 behind the scenes?
    This came up at a discussion at my site very recently, and I think I can just point them to your example here as a demo rather than creating my own. I assume that if you ran the same thing in 9iR2, then that first fetch of rows in TKPROF would only show 1?
    Followup April 18, 2007 - 1pm US/Eastern:
    yes, that demonstrates the implicit array fetch of 100 rows...
    in 9i, it would show 1 row fetched.
    Edited by: Etbin on 31.5.2009 10:38

  • Will using for loop decrease the performance

    Hi,
    Will using for loop with a query decrease the performance.
    for r_row in (select * from table) Loop
    end loop.
    This is done inside another for loop, most of the cases it returns only one value.
    will it decrease the peformance of the procedure.
    kindly advice.......
    Regards,
    Balu

    user575682 wrote:
    Will using for loop with a query decrease the performance.
    for r_row in (select * from table) Loop
    end loop.
    This is done inside another for loop, most of the cases it returns only one value.
    will it decrease the peformance of the procedure.Perhaps it is better to understand just what this PL/SQL loop construct does.
    PL/SQL is two languages. It is PL (programming logic code) like Pascal or C or Java. You can use a 2nd language inside it called SQL. The PL engine is clever enough to recognise when the 2nd language is used. And it compiles all the stuff that is needed for the PL engine to call the SQL engine, pass data to the SQL engine and get data back, etc. (compare this with the complexity of using the SQL language in Pascal or C or Java).
    So what does that loop do? The PL engine recognises the SQL SELECT statement. It creates an implicit cursor by calling the SQL engine to parse it (hopefully a soft parse) and then execute it.
    As part of the PL loop, the PL engine now calls the SQL engine to fetch the data (rows) from the cursor. With 10g and later, the PL engine is smart enough to use implicit bulk processing.
    Prior to 10g it used to fetch a row from the SQL engine, do the loop, fetch the next row, do the loop, etc. This means if there is a 1000 rows to fetch, it will call the SQL engine a 1000 times.
    With 10g and later it will fetch a 100 rows, store that in an internal buffer and then do the loop a 100 times. With a 1000 rows to fetch, it now only requires 10 bulk fetches instead of a 1000 single row fetches.
    These fetches require a context switch - as the PL engine has to step out and into the SQL engine and back, to fetch a row. This is an overhead and thus can become slow the more context switching there is.
    And this is the basics for this loop (and most other cursor loops) construct in PL/SQL.
    The ideal is to reduce the number of context switches. This is an overhead that can impact on performance.
    What about using a loop within a loop. Also "bad". This uses the outer loop to fetch data. This data is then used to drive the fetch in the inner or nested loop. So the outside loop pulls data from the SQL engine into PL variables. The inside loop pushes that very same data back to the SQL engine.
    Why? It would have been a lot faster no to pull and push that data between the loops using PL.
    It will be a lot faster doing it via SQL only. Write both loops as a single SQL statement and have the SQL engine directly drive these loops itself. This is called a JOIN in SQL. And the SQL engine can do it not only faster, but it has some froody algorithms that can be used that are even faster than a nested loop process (called merge joins, hash joins, etc).
    Bottom line. Maximise SQL. Minimise PL.*
    Do as much of your data crunching in SQL as possible. SQL is the best and fastest "place" to process data. Not PL (or Pascal/C/Java).

  • Nested for loop

    hello
    how can i implement this code in labview. i am new to labview, so plz if u design a vi of this code.
    for i=1:m
    c = (i-m/2);
    for j=1:n
    d = (j-n/2);
    N1(i,j)=exp(-(c^2+d^2)/c1^2);
    end
    end
    wher m is num of rows and n is number of column and c1 is a constant
    thnx
    kitty

    Here's a quick framework for you to start with.  I left out most of the math.
    Some things to notice:
    The i terminal starts with 0 and counts up for each iteration.  Since you want your math to start with 1, you need to increment.
    See the autoindexing out of the FOR loops?  That's what is building up your 2D array.
    Since you claim to be new, you might want to check out some of the online tutorials.
    LabVIEW Basics
    LabVIEW 101
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Nested loop.png ‏13 KB

  • Tough Nested FOR loop

    Friends,
    I am very new to Java and am trying to understand nested loops. Could someone please explain (step by step) how/why the code below returns 001012 ?
    public class ForLoop
    public static void main(String[] args)
    for (int a = 0; a < 3; a++)
    for (int b = 0; b <= a; b++)
    System.out.print(b);
    Thanks,
    Mark!

    I'm sure you can Google yourself some good info on nested loops, but the post Walken16 gave you:
    public class ForLoop
       public static void main(String[] args)
          for (int a = 0; a < 3; a++){
             System.out.println("in outer loop, a = "+a);
             for (int b = 0; b <= a; b++){
                System.out.println("in inner loop, b = "+b);
    }...should give you what you need. The key is to understand when the loops start and stop. The println's in there should illustrate this nicely if you think about it.

Maybe you are looking for

  • External Hard Drive Not recognized when trying to boot from it.

    So I am trying to boot from my external hard drive through firewire but my computer doesn't seem to recognize the external. There is some problem with my Macbook not booting up correctly and I want to backup my data before reinstalling Tiger. They di

  • My camera creates .avi files, imovie can't read them

    I have a camera that creates .avi files and I wanted to use imovie if possible or another software to create movies if imovie won't work, can anyone suggest what I need to do?

  • Forefront TMG to SRP527w

    I ma trying to setup a IPSEC site to site VPN between MS Forefront TMG 2010 to a Cisco SRP527W router I am running the latest firmware on the router I cannot get the 2 to connect, I have matched as best as possible the settings on the SRP527W as are

  • Safari's Unusual Download Behavior

    Morning - I've been a long time Chrome user, but after some performance and slowness issues, I've come back to Safari and have really been enjoying the quickness of the browser. The only thing causing me problems is the way Safari downloads files. In

  • Cannot download 3.06 ovi maps for 5800XM after har...

    Cannot download 3.06 ovi maps for 5800XM after hard reset. Any clue what's going on?