Multiplying elements of two different arrays

hey, I have a while loop thats performing two separate operations similtaneously and filling the data elements of two different 1d arrays with data.with each iteration of the loop a new value pass from an operation to an array.
I need to multipy to corresponding elements of the arrays such the first element of one array is skipped. so element i0 * element j1 , element i1 * elemnent j2 etc. how can i acess the elements and make the calculations? arrays could have hundreds of elements.
Thanks.
Brendan

blue silver wrote:
hi Peter,
I have an array of 2,000,000 values (each long int). I need to do an "Moving average" operation which would than:
1) takes average of the first 10 values , plots it
2) remove the first value ,add 11.th value, take average, plots it in the next 100 ms in the chart
3) remove the first value, add 12.th value, take average, plots it in the next 100 ms in the chart
(as you see , it is a kind of shifting) the averaged array elements is always 10 , and after averaging those 10 elements , plot it with 100 ms distance in the graph.
1999989)  remove the 1,999,989 th element , add the last element
you have a possible idea ?
your help will be tremendously appreciated.
Regards
Silver
Try this.  It iterates 10 times taking a subset of the array each time to sum it to a shift register.  When done, divides by the total number of iterations.  So it adds i0 to i1 to i2 to i3 to i{N}.  For each element from i0 up.  It will give you an array where n elements are missing  (because elements 0 through n-1 don't have N samples to average to.
Message Edited by Ravens Fan on 11-26-2007 09:26 PM
Attachments:
Example_BD.png ‏4 KB

Similar Messages

  • Comparison of Elements of Two 2D Arrays

    Hello!
    I am trying to compare elements of two 2D Arrays and find at least one pair of elements that are identical. Browsing the forum I found one method suggested by Altenbach (http://forums.ni.com/t5/LabVIEW/Compare-elements-in-an-array/m-p/458622). However, it works well with 1D Arrays. That is why I rearranged the original code for my case, but unfortunately the attempt was unsuccessful. Could anyone please have a look at my VI and suggest any solution? 
    Thank you.
    Solved!
    Go to Solution.
    Attachments:
    Search and Compare Indices.vi ‏16 KB

    Thanks, paul_cardinale !
    It works.. Now I see the principle. 
    Sometimes, the algorithm works perfectly, but sometimes it detects only one common index.
    For example, 
    3 5   and  5 5 6
    1 0            0 1 7
    In this case (5,0) is common for both arrays. But the algorithm shows that only "5" is common. Why do u think it is happening? 
    I have attached VI. 
    Attachments:
    Search and Compare Indices.vi ‏19 KB

  • How to enter two different arrays into two columns of a multi column listbox

    Hi All,
    I have two different arrays of values suppose 1 array A(1,2,3,4,5) and another array B(3,4,5,6,7). I want to write these to arrays into a multicolumn listbox such that 1st column would be array A and 2nd column would be array B.
    Thnx in advance
    Solved!
    Go to Solution.

    I still couldnt understand how to do it...
    I am posting here my VI. here the 1, 2, 3, 4 are some controls. If i enter any value, the calculated Voltage and current are continously pushed in the array. Now i have display these arrays in the multi column listbox as 1st column be the voltage and second column being the current.
    Attachments:
    manual_graph.vi ‏643 KB

  • Read two different arrays and display

    I have a text file, which has 1000 of entries in the way mentioned below:
    Kozos customer
    sabze employee
    I am reading the content of text file and saving as an arrays.
    $global:Content = get-content info.txt
    $global:Name=$Content | foreach {
    $hashTab=@{Name="" ; Info=""}
    $hashTab.Name, $hashTab.Info=$_.Trim() -split '\s+'
    New-Object PSObject -Property $hashTab
    $global:Names=$ServerList | select -ExpandProperty Name
    $global:Infos=$ServerList | select -ExpandProperty Info
    How do I read two arrays, I mean read the values of two arrays one by one and display the result as:
    Names Infos
    Kozos Customer
    sabze employee

    We get that you are unable to do this, but it is still not clear precisely what it is that you want, a two-dimensional array, or a structure such as SeanQuinlan suggested? Also:
    there seems no reason for any of the variables to be global in scope.
    Where is the $serverlist variable defined?
    what relationship is there between the file you mention and the data in the $serverlist variable?
    Your code has three arrays, $name, $names, and $infos; which two of these do you want to combine into a single array? If $names and $infos, would this work for you:
        $namesNinfos = $serverlist | select name,info
    I suggest that you describe your situation without trying to state it in powershell (as that is partly where your problem lies). You could, for example, show sample content of the file and each of the two arrays, and show what this would look like in your
    desired two-dimensional array, perhaps like this:
    file info.txt
    Kozos customer
    sabze employee
    array 1:
    Kozos
    sabze
    array 2:
    customer
    employee
    resultant 2D array
    column 1 2
    row
    1 Kozos customer
    2 sabze employee
    As an aside, it could be that we are getting confused by the term "array". languages such as fortran and basic support multidimensional arrays in which each element is addressed by a set of integer indices, the most common form being row and column, as in
    a spreadsheet.
    In Powershell, arrays are generally one dimensional, with a single numerical index being used to select a single element ($row3 = $array[2]). That element can optionally have multiple values if it is defined as an array or a hash. This is referred to as
    a "jagged array" as each element of the array may not all have the same number of sub-elements as each other.
    Powershell also supports true multidimensional arrays, however, these seem fairly rarely used, I suspect because jagged arrays generally provide more easily used functionality.
    You can get more details on this from
    here and
    here.
    This, then, leads to my final question:
    what type of two-dimensional array are you looking for, and how will your script be processing it?
    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

  • Am I able to install Elements on two different computers?

    I'm looking to purchase Elements 13 and am wondering if I can have it installed on two different computers? TIA!

    You bet.

  • Map one source elements to two different target elements

    Hi Gurus,
                In our scenario, we have single source. and we are mapping this single source to two different structures, based on condition in the source records on one field, we are mapping to either X structure or Y structure. in my case i have to generate only one file at a time based on condition.
              If condition is true, i have to mapp it for X structure, if its false i have to mapp it for Y structure. but in my case i getting a blank file for another mapping. i should stop this blank file.
             any suggestions and solutions will be rewarded. this is an urgent issue, please help me.
            Thanks in advance.... 
    Thanks & Regards,
    Anuj..

    I have already used an if-then construct and an enhanced ID.Thanks anyway.
    Let me explain using a source interface (s1) and target interfaces t1 and t2.
    Based on the condition, only one interface(lets say t1) will be selected, target mapping is done for this.
    But the problem is that the other interface (t2) also executes(having only the root node) and the end result is i have two files - one with the mapped payload and another empty one with only the root node.
    My requirement is to remove this empty file at the mapping stage itself , as -
    1) i only need a single file at the receiver.
    2) i do not want an extra payload for every record i send, creating unnecessary load on my IE.
    Also due to performance issues i do not want to move this to a BPM.
    I have attached the o/p screenshot at http://www.flickr.com/photos/14210232@N03/1550768802/
    In window 1 i have the correct output .i.e of the interface t1 which was mapped.
    In window 2 i have the unwanted output. i.e the interface t2 which is creating another file at the receiver.
    <b><b>Ques</b></b>: When using enhanced ID/multi-mapping, under Messages tab, if i set my target message type to 0..1, should it not work? I have tried this but it doesn't.
    Do let me know a way out! Thanks.
    Anuj.

  • Cross checking values from two different arrays

    Hi there,
    I need some help with figuring out how to do this and hopefully someone here can help:
    I've got movieclips of dice called "dicePicked1", "dicePicked2", etc all the way to 6. each of these movieclips has a graphics on keyframes with labels "One" to "Six".
    Now I'm trying to find (in vain) a way to cross check the labels with arrays of numbers so that each time it finds a dicePicked with the appropriate label, it moves onto the next number to find. For example, I need to see if one of each dice has [1,2,3,4,5,6]. Once the program finds a dicePicked with the Label "One", it moves onto the next element which is 2 and so on.
    If it finds the last element (and thus all the elements), it returns true. If it doesn't find an element (for example none of the dicePicked have a Label "Three") then it returns false. I'm trying to find a system that can accommodate different combinations and some with the same numbers multiple times (for example 3 different dicePicked have the label "three")
    I'm having alot of trouble figuring out a good system for this and any help would be awesome!
    Thanks and let me know if anything is unclear!

    Unfortunately, your example lost me on the first roll... I don't see the combination in choosing the 1 and the 5 for 150 points.  That would have me think that the roll with the 4 could be kept for 40 points.  Also, I didn't see where getting a 5 or a 1 for the last roll would have yielded something.
    Anyhow, if you look at what I did for the Yahtzee game, each possible combination has a function dedicated to testing for it.  The difference with Yahtzee being that you have to choose which scoring element you use up for each turn, whether you earn that scoring element or forfeit it.  Also keep in mind that I created that tangle of code when I was a youngin' in the programming realm, so there may be cleaner ways of dealing with things.
    Since you appear to be automating the scoring process, you likely need to have something first detect that the "hold these" action has taken place and then do some evaluation on those held thru a top-down series of checks (meaning highest scoring combinations to lowest), and accept the first that fills the bill.  I don't understand the logic as to why a 1 and a 5 score anything, but in any case, your code would need to have a test for that scenario.  And if having the last die be a 1 or a 5 also scores, then you would need to retain something relative to that relkating to the 1 and 5 being selected earlier.

  • Specifying nested element with two different XML Schema

    Hello,
    I am trying to convert one xml file to another file. I figure data services would be great for this.
    My problem relates to how to have a source xml file with a certain xml schema be transformed to one of a different xml schema. I cannot build the nested elements of the target schema.
    From the source xml I only need four fields. But they need to be nested three levels in the target xml.
    Source
    <DRUG_PRODUCT_LST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <DRUG_ITEM>
          <DRUG_PRODUCT_ID>113083</DRUG_PRODUCT_ID>
          <DIN_PDIN>2317559</DIN_PDIN>
          <HC_BRAND_NAME>PMS-SILDENAFIL</HC_BRAND_NAME>
          <HC_ATC_CODE>G04BE03</HC_ATC_CODE>
       </DRUG_ITEM>
    <DRUG_PRODUCT_LST
    Target
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <CODES>
       <CODE_TYPES>
          <CODE_TYPE>
             <COD_CODE>113083</COD_CODE>
             <COD_DESCR>PMS-SILDENAFIL</COD_DESCR>
             <COD_SOURCE>G04BE03</COD_SOURCE>
             <COD_NPSA>2317559</COD_NPSA>
          </CODE_TYPE>
       </CODE_TYPES>
    </CODES>
    I have tried using an xml pipline to unnest the source, then use a query transform to re-nest for the target. But I do not know how to specify the input schemas.

    Hello,
    I am trying to convert one xml file to another file. I figure data services would be great for this.
    My problem relates to how to have a source xml file with a certain xml schema be transformed to one of a different xml schema. I cannot build the nested elements of the target schema.
    From the source xml I only need four fields. But they need to be nested three levels in the target xml.
    Source
    <DRUG_PRODUCT_LST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <DRUG_ITEM>
          <DRUG_PRODUCT_ID>113083</DRUG_PRODUCT_ID>
          <DIN_PDIN>2317559</DIN_PDIN>
          <HC_BRAND_NAME>PMS-SILDENAFIL</HC_BRAND_NAME>
          <HC_ATC_CODE>G04BE03</HC_ATC_CODE>
       </DRUG_ITEM>
    <DRUG_PRODUCT_LST
    Target
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <CODES>
       <CODE_TYPES>
          <CODE_TYPE>
             <COD_CODE>113083</COD_CODE>
             <COD_DESCR>PMS-SILDENAFIL</COD_DESCR>
             <COD_SOURCE>G04BE03</COD_SOURCE>
             <COD_NPSA>2317559</COD_NPSA>
          </CODE_TYPE>
       </CODE_TYPES>
    </CODES>
    I have tried using an xml pipline to unnest the source, then use a query transform to re-nest for the target. But I do not know how to specify the input schemas.

  • Multiplying data at two different levels

    I have Actual Forecast Bias data generated at a particular level (%Bias). I want to multiply this against other data that is at a different level in the same cube so as to adjust the forecast in line with actual performance. The Bias% data is at Battery Part# level. The data that I want to multiply it against is Appliance/Battery level. When I run it, the multiplication operates against a rolled up consumption level for all appliances that use a particular battery. I need the Bias % to operate at the battery level, not the rolled up level..
    I'm a newbi at this so any help welcome
    See the code below
    FIX (Batteries, @IDESCENDANTS ("A Size Family"),appliances,ww,@idescendants(NA));
    "New forecast %" = #Missing;
    "Bias %" = #Missing;
    "Bias %" = ("trade units" -> Actual/"trade units");
    ENDFIX;
    FIX("wif 1")
    FIX (@LEVMBRS(appliances,1),@levmbrs(Batteries,0), @IDESCENDANTS ("A Size Family"),ww,@idescendants(NA));
    "New forecast %" = consumption*"Bias %";
    ENDFIX;
    ENDFIX;
    FIX("wif 1")
    CALC DIM (WW, Supplies, Printers);
    ENDFIX;

    Hi Johnnie
    I assume the important bit is the bit within the second fix:
    "New Forecast" = Consumption * "Bias %";
    The way you have your fix statement set up it is looking at level 0 members in your Appliances and Batteries dimensions (I'm reading your post as if they are separate dimensions). I assume your issue is that the one piece of data is at level 0 interesections of appliances and batteries but the other piece is not possibly at level 0 of one dimension and level 1 or higher of the other, Bias% being the one at the higher level?
    If that is the case then I think you need to look at a way of getting from the level 0 member to the correct intersection point(s).
    Have you had a look through the technical reference at functions like @PARENTVAL, @ANCESTVAL or the multidimensional options for the same @MDPARENTVAL and @MDANCESTVAL, it sounds like your formula needs to be something along the following lines
    "New Forecast" = Consumption * @PARENTVAL(Appliances, "Bias%");
    What the above would do differently to your original code would be to get the Bias % value from the parent of the current level 0 member of the appliance dimension being calculated. While this might not be exactly what your requirement is hopefully it will steer you in the right direction.
    Hope this helps
    Stuart

  • Macro - multiply numbers at two different levels

    Hi Folks,
    I am trying to write a macro which takes KF at a detailed level and multiplies it with another key figure at a different level of aggregation. Any ideas in this direction will help.
    A - B
    KF 1 = 10 %
    A - C
    Kf 1 = 20%
    A
    KF 2 = 100
    I want to write  a macro that gives following result
    A - B
    KF3 = 10 ( 10% * 100)
    A - C
    KF3 = 20 ( 20% * 100)
    Regards,
    Sachin
    Edited by: Sachin Ganesh Shetty on Feb 12, 2009 4:57 AM

    Hi,
    I had a similar requirement of running a macro at 5 level and use a data at 3 level as one of the inputs.
    what i did was i wrote a Z function module which called /sapapo/msdp_data_read and retrieved the value at 3 level.
    Thus i was able to extract a 3 level value and use it to run a macro at 5 level.
    Please let me know if this helps.

  • Why i get different value when subtractin​g two elements of different arrays then the actual value in a timed loop

    Hi Everyone
    I have a probem in substracting the two elements of two different  1-D arrays. The problem is, I am taking out data from a CCD camera which gives me data in form of 2-D array. So i select 1-D array out of it. Now this CCD output is in a timed loop, hence i am getting data in each loop. I select a perticular array output of the CCD and this is then passed to shift register and in all the loops later on, one of the element of the output array of the CCD is substracted from the same indexed element of the selected array. For reference i have pasted the snap shot of the block diagram. In this snap shot you see three probes. The value at the prob 1 is 232, at probe 2 is 255 and at 3 is 4294967273, where as actually i sould have a value of -23 since i am substacting prob 1 and probe 2 values. Since the value of probe 2 will always remain at 255 as i have fixed it by choosing an array form CCD and i checked the value of probe 1 which never goes above 255 so why do i get this false value here.
    Can you please help me in problem.
    Regards
    Chauhan
    Attachments:
    clip_image0011.gif ‏15 KB

    Your data is U32 (unsigned integer) which does not have negative values. According to unsigned integer math, "negative" results will wrap.
    You need to work in a datatype that is appropriate for what you want to do. How many significant bits do you have in the raw data?
    Message Edited by altenbach on 03-17-2008 11:15 AM
    LabVIEW Champion . Do more with less code and in less time .

  • How to open a raw image with two different exposures?

    Hello,
    I am trying to open a raw image file in Elements with two different exposures so that I can use an adjustment layer to blend the exposures. For the life of me, I cannot figure this out, and the online help is completely useless. I have read everything in the online help about working with layers and it does not mention a single thing about this process. I know it can be done because I have done it before with a previous version of Elements, but I remember it being a very awkward experience. Can anyone point me to a page with this technique, or share the secret? Thanks. If anyone from Adobe is watching this forum, please try to make this product easier to use, more intuitive, and less reliant on subtleties, and by all means, PLEASE improve the documentation as it is practically empty of any useful information.
    Thanks,
    Shan

    I tried that. When I open one image and set the exposure, then go to open the second image, nothing happens. I then saved one image as a psd file, then it would let me open the raw file a second time. When I had both open on the same screen and dragged the layer from one into another image, the layer size ended up being different than the other file. It was shifted down and to the left. I need these images to be pixel locked, and the user experience I went through did not allow me to do this.
    I also do not see a way to copy/paste layers between files.

  • Can;t find what is wrong. Trying to add elements in two arrays

    Hello everyone
    I'm trying to take as input two numbers, convert them to arrays and add all the element of the array one by one. I want the result to be the sum of every element of the array. Let's say array1={1,2,3,4} and array2={2,6,4,3} I want the final result to be 3877.
    If the sum of one element of the array is greater than nine, then I would put zero and add 1 to the element on the left.
    Here is the code:
    import javax.swing.JOptionPane;
    public class Main {
        public static void main(String[] args) {
            String numberOne = JOptionPane.showInputDialog
                                    ("Enter the first number: ");
         String numberTwo = JOptionPane.showInputDialog
                                    ("Enter the second number: ");
            //compare string length and make them equal length
            int[]n1 = toArray(numberOne); // my first array
         int[]n2 = toArray(numberTwo); // my second array
         //call the method that ads both strings
         int[]finalArray = arrSum(n1,n2);
           JOptionPane.showMessageDialog(null, "The sum of the two numbers is: "
                   + finalArray);
        }//end of main
        //method to create an array from a string
        public static int[] toArray(String str)
                int[]arr = new int[str.length()];
                arr[0]=0;
                for (int i=1; i<str.length(); i++)
              arr= Character.digit(str.charAt(i),10);
    return arr;
    }//end of toArray
    //method to add arrays by elements
    public static int[]arrSum (int[]arr1, int[]arr2){
    for (int i = arr1.length-1; i >=1; i--)
    int sum = arr1[i] + arr2[i];
    if (sum > 9)
              { sum -= 10;
              arr1[i-1]++;
    return arr1;
    }//end of arrSum method
    }Edited by: designbc01 on Feb 16, 2010 1:15 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    The best advice I can give you is to break your problem up into smaller pieces. First, focus on a method that converts an input String into an array. When you have that working perfectly, then focus on creating a method that "adds" two arrays with the logic you described. When you have that working perfectly, then combine the two different pieces.
    Why does your for loop in toArray( ) start with 1? The first index of a String, array, or pretty much anything else, is zero.

  • Error after creating Element level join between two different dataset in11G

    Hi Experts,
    My report is having data from two different datsets, I created two datasets and joined them with Element Level join. I am getting below error.
    "The following tags were not closed: DATA_DS. Error processing resource 'http://localhost:9704/xmlpserver/servlet/xdo'. "
    But independent datasets are executing with out any errors.
    Please let me know, If any one have inputs to resolve this.
    Thanks in advance..

    Hi,
    Can you please explain the resolution in more details. I'm also having the same issue in BI Publisher report when trying to join two data sets with Element Level Link. I have checked that all my columns have alias names.
    Thanks,
    Piya.
    Edited by: 947289 on Jul 18, 2012 5:56 AM

  • I have "chatted" with customer service 5 different times. I was sent here. I have activated Photoshop Elements 9 on two different iMacs. They are both dead and I am unable to get it to activate on my newest computer. iMac. Can anybody help me?

    I have "chatted" with customer service 5 different times. I was sent here. I have activated Photoshop Elements 9 on two different iMacs. They are both dead and I am unable to get it to activate on my newest computer. iMac. Can anybody help me?

    Unfortunately, only adobe can help you with that, as most people here are just posters such as your self and don't work for adobe.
    If you go here and use the Chat now button (bottom of page), they should get you up and running by resetting your activations.
    http://helpx.adobe.com/x-productkb/policy-pricing/activation-deactivation-products.html

Maybe you are looking for