Merging elements of array

Hi,
I am new to programming.
I have a sensor that sends a data stream through a serial port. I have collect all that data in a 1D unsigned byte array. Now, lets say my 1-D array is [12][45][65][12]...... where each "[ ]"  is a element of the array. Now to make sense of this data what i need to do is merge two elements the array and multipy it by 2/(2^15). i.e. My converted data should by [1245]*2/(2^15). Basically 2 bytes together makes sense. I can do a simple add of each element. Also the other problem is,data from the sensor is a stored as the 1-D array  of unsigned byte. However, the converted data is supposed to be signed 16-bit integer.
Please give any suggestions on how to go about doing this.
Siddhant Shah

Another option is "decimate&Join". (Here it is easy to change the byte order if needed).
Message Edited by altenbach on 12-15-2008 06:28 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
8bitTo16BitByteOrder.png ‏5 KB

Similar Messages

  • Merge data Using Array records. Possible?

    Hi,
    I have a package with an array of emp%rowtype declared.
    I now want to use merge. I.e if the elements of array is found in table, upate it else insert.
    I am geeting compling errors table does not exist.
    Can merge be used this way?
    Please guide..
    CREATE OR REPLACE PACKAGE UPD_emp_ALl AS
    TYPE Varry_emp IS TABLE OF emp%ROWTYPE;
    PROCEDURE UPD_emp(emp_rec in Varry_emp);
    end UPD_emp_all;
    CREATE OR REPLACE PACKAGE BODY UPD_emp_All AS
    PROCEDURE UPD_emp(emp_rec in Varry_emp) is
    BEGIN
    MERGE INTO emp T
    Using emp_rec V
    ON (T.emp_id= V.emp_id and
         T.emp_dept=V.emp_dept)
    WHEN MATCHED THEN
    UPDATE set
    T.col1 = v.col1,
    T.col2= v.col2,
    so on...
    WHEN NOT MATCHED THEN
         Insert (T.col1,T.col2,T.col3,...)
         vALUES (V.col1,V.col2,V.col3,...);
    END UPD_emp;
    END UPD_emp_All;
    /

    Thanks Avinash.
    Even if i declare a variable of same type as emp_rec,
    inseide my procedure, how do i assign my new_array with values of the ones that has been passed through a parameter?
    Plz help..
    I get an ARRAY as a parameter in the procedure.
    Need to use it to merge with a Table.
    CREATE OR REPLACE PACKAGE UPD_Pemp_all AS
    TYPE Varry_emp IS TABLE OF emp%ROWTYPE;
    PROCEDURE UPD_emp(emp_rec in Varry_emp);
    end UPD_PATCH;
    CREATE OR REPLACE PACKAGE BODY UPD_emp_ALL AS
    PROCEDURE UPD_emp(emp_rec in Varry_emp) is
    BEGIN
    FORALL I IN emp_rec.first..emp_rec.last
    MERGE INTO emp T
    Using dual V (also tried using select * from Table(emp_rec))
    ON (T.emp_id= emp_rec(i).emp_id and
    one more cond)
    WHEN MATCHED THEN
    UPDATE set
    t.cols=emp_rec(i).cols
    WHEN NOT MATCHED THEN
    Insert (stuff here)
    END UPD_PASTATUS;
    END UPD_PATCH;
    The FOR ALL is not working, thows erros cannot bind etc.. I am Using Oracle 10g Rel2
    Thanks for any help.

  • The prefix mx for element mx:Array is not bound

    Hi All
    I have a component:
    <?xml version="1.0" encoding="utf-8"?>
      <mx:Array id="arr">
        <mx:Object label="Flex"
          thumbnailImage="http:/someURL"
          fullImage="http://someURL" />
      </mx:Array>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
    </mx:Canvas>
    This gives me an error
    The prefix "mx" for element "mx:Array" is not bound
    I need a root element here, but I cannot use mx:Canvas, what would be the best choice?
    cheers
    Luca

    Hi Luca,
    Try to put the Array inside your canvas rather than outside ...
    <?xml version="1.0" encoding="utf-8"?
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Array id="arr">
        <mx:Object label="Flex"
          thumbnailImage="http:/someURL"
          fullImage="http://someURL" />
      </mx:Array>
    </mx:Canvas>
    Why  you dont want to use mx:Canvas as root tag of your component.. ?? However which ever component you use try to put the <mx:Array/> inside your root tag of your component, otherwise you will be thrown the same error as mentioned. The error occurs as the the compiler doesn't recognize the namespace mx for the array since you declared it outside the root tag of your component.
    Thanks,
    Bhasker

  • Remove element from array

    hi
    if i have an array
    eg
    int[] array = {4,2,1,2,1};
    how to i remove the index 2 from it and create a new array?
    thanks

    You can't remove the element--an array's size is fixed at creation.
    If you want a new array, create a new one that's one element smaller, then use System.arrayCopy to copy the elements you want to keep.

  • How can i retrieve missing element in array

    how can i retrieve missing element in arrays if array length is exceeded

    Not sure about what the question means, but could it be that OP is not aware that the first element in an array is at index 0 (not 1) ?
    <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html" style="background:url(http://java.sun.com/docs/books/tutorial/figures/java/objects-tenElementArray.gif) no-repeat; width:400; height:145;"></a>

  • Unable to merge two byte arrays

    Hi there,
    I am trying to merge two byte arrays into one byte array
    and write into a new word document using OutputStream object.
    But in the new word document that is created only the contents
    of the first byte array are being shown and not that of the second one.
    I have pasted the code below.
    Any pointers will be of great help.
    Thanks and Regards,
    Partha.
    package com.cisco.asit.icn.common.servlets;
    import java.io.ByteArrayInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import org.apache.poi.hwpf.HWPFDocument;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;
    public class TestPOC {
         public static void main(String[] args) {
              try
                   System.out.println("I am here...");
                   System.out.println("I am in example 4...");
                   byte[] byteAr1 = getBytesFromFile(new File("c:\\Testing_POC\\Not_blank.doc"));
                   System.out.println(byteAr1.toString());
                   System.out.println();
                   byte[] byteAr2 = getBytesFromFile(new File("c:\\Testing_POC\\Quest.doc"));
                   byte[] finalOne = concatenate(byteAr1, byteAr2);
                   System.out.println("byte array 1..."+ byteAr1.length);
                   System.out.println("byte array 2..."+ byteAr2.length);
                   System.out.println("Final byte array ..."+ finalOne.length);
                   InputStream is = new ByteArrayInputStream(finalOne);
                   POIFSFileSystem fss = new POIFSFileSystem(is);
                   OutputStream out1 = new FileOutputStream("c:\\Testing_POC\\Result.doc");
                   fss.writeFilesystem(out1);
                   System.out.println("Stored to file system...");
                   try {
                        Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL \"" + "c:\\Testing_POC\\Result.doc");
                   catch (IOException e1){
                        e1.printStackTrace();
                   System.out.println("I am fine till here...");
         out1.flush();
         out1.close();
         catch (Throwable t) {
         t.printStackTrace();
         byte[] res = new byte[l.length + r.length];
         System.arraycopy(l, 0, res, 0, l.length);
         System.arraycopy(r, 0, res, l.length ,r.length);
    return res;
         public static byte[] getBytesFromFile(File file) throws IOException {
    InputStream is = new FileInputStream(file);
    // Get the size of the file
    long length = file.length();
    // You cannot create an array using a long type.
    // It needs to be an int type.
    // Before converting to an int type, check
    // to ensure that file is not larger than Integer.MAX_VALUE.
    if (length > Integer.MAX_VALUE) {
    // File is too large
    // Create the byte array to hold the data
    byte[] bytes = new byte[(int)length];
    // Read in the bytes
    int offset = 0;
    int numRead = 0;
    while (offset < bytes.length
    && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
    offset += numRead;
    // Close the input stream and return bytes
    is.close();
    return bytes;
    }

    parthInfy wrote:
    Hi there,
    I am trying to merge two byte arrays into one byte array
    and write into a new word document using OutputStream object.
    But in the new word document that is created only the contents
    of the first byte array are being shown and not that of the second one.
    Because the end of the first byte array contains a "document ending" tag and anything after that is just flotsam. And, even if you could remove that "document ending" tag, there is for the second a "document begin" tag. (Among many other tags and flags in both documents.) Word (ar just about any) documents are not simple text files to be concatented, truncated, twisted, inverted, or whatever else, at your pleasure. You actually, God forbid, have to kinow what you're doing, to manipulate them at this level. And, surprise, surprise, you don't.
    Edit: Google "POI"

  • How to change a specific element in array

    hi 
    i have an 1d intialized array
    i want to take the existed array and for example add +1 for the 5th element
    how can it be done?
    thanks
    Solved!
    Go to Solution.

    In a typical application you would want to repeat that operation to form a simple histogram. This is most easily achieved by keeping the array in a shift register and repeating the operation in a FOR loop until all data is processed.
    My very simple example from a few years ago can be found here. In this case we are counting the number of occurences of small integers in a 1D array. Modify as needed.
    LabVIEW Champion . Do more with less code and in less time .

  • Web service proxy receiving single element in array

    I've generated a web service proxy over a web service and expect to get multiple elements returned from the web service. However when I excute the proxy I receive only the first element. Testing the web service with the same parameters on the application server shows that I should be receiving 3 elements in total. Not sure where the disconnect is in generating the response message within the proxy. Any suggestions is appreciated.

    Are you looking for SOAP ENC Array feature? Which version are you using 10134 or 11g?

  • Dynamically create empty mcs and asign elements from array and loadmovie

    I'm creating an educational game for my school students.
    A little boy is flying through the city when he encounters objects flying from left to right.
    He hears a SOUND eg: Dog - he must go and click the dog image with the flying cursor. There are at least 5 DIFFERENT objects that should be flying on the screen. There could be various of them at any one time.
    I have the roots of the images in an xml file. And the actual swf are in a file called IMAGE and the sounds in SOUND.
    My problem is that most tutorials I see use the attachmovie method but I don't want to put all the swf's in the library as there are hundreds.
    I have to use the loadmovie method.
    I take it I have to loop through the array and assign each element to an empty movieclip which in turn is in the loop so you get 5 empty clips - I will use i (index). It doesn't seem to be working. I shall keep trying and post back here if I get any luck but I'm running out of ideas.
    Then the objects have to float across the screen. Don't know whether to use tween object or onEnterFrame handler or other. AND someone has mentioned using setinterval to "spit out" the objects.
    BUT if I have five flying across the screen I'm left without clips to stick in any more.
    Oh my head hurts but I will keep going.
    CHEERS if any help is around. This should be quite a standard thng for game developpers. Code at the moment
    function loadEnemies():Void {
    enemy_xml = new XML();
    enemy_xml.ignoreWhite = true;
    enemy_xml.onLoad = function(success:Boolean) {
    if (success) {
    _root.parseEnemyXML();
    //enemy_xml.load("level_"+level+".xml");
    enemy_xml.load("data/animal_catch.xml");
    function parseEnemyXML():Void {
    rows = enemy_xml.firstChild.childNodes.length;
    for (var i:Number = 0; i<rows; i++) {
    var row_string:String = String(enemy_xml.firstChild.childNodes[i].firstChild.firstChild);
    _root["row_"+i+"_array"] = row_string; //MAIN ARRAY holds an array images/dog_a.swf/ images/cat_a.swf etc... all five
    _root.createEmptyMovieClip("enemyObjects", 1);
    enemyObjects.createEmptyMovieClip("holder_"+i, i);
    _root["object"+i] = new Sound(enemyObjects["holder_"+i]);
    trace(row_string);
    loadMovie["row_"+i+"_array"], ["holder_"+i]
    if (level == 1) {
    alerts_mc.play();
    } else {
    currRow = 0;
    rowCounter = 0;
    OK got to about here BUT
    a. I started to get confused around the createEmptyMovieClip part
    b. I KNOW I shouldn't have Sound(enemyObjetcs etc... BUT I copied the code from a tutorial and I don't know what to replace it with.
    I'm close but I need a little polishing.

    It doesn't do you much good to work with borrowed code that you do not understand.  Your best bet will be to start small, creating one functional piece of the puzzle at a time, and work your way up.  Start with making sure you are loading and parsing the xml properly, then set about loading the external content, then see about making that content move around, etc...
    In the code you show, your loadMovie line of code does not resemble anything I have seen before, looking more like (but not quite like) a multi-dimensional array element than a loadMovie() function call.  If you find you need to have control of the items as soon as they load, then you should consider using MovieClipLoader.loadClip instead of loadMovie.  The MovieClipLoader class provides features, such as to be able to determine when items have fully loaded.

  • Add element in array

    Hi,
    I have one String array.
    I need to create another String array with the content of 1st array and additional 1st element in the 2nd array with "Product" text.
    2nd array[0] = Product;
    How do i do it
    Thanks

    String[] array1 = {"1", "2", "3"};
    String[] array2 = {"4", "5"};
    String[] array3 = new String[array1.length+array2.length];
    System.arraycopy(array1, 0, array3, 0, array1.length);
    System.arraycopy(array2, 0, array3, array1.length, array2.length);
    here, the array3 will have all the elements in order ie, 1,2,3,4,5.
    In case you need to use array2, assign array3 to array2 ie, array2 = array3
    Hope that helps.
    Regards,
    Sumant

  • Sort Second Element in Array of Strict Type Def Clusters

    I need to sort the an array of strict type def clusters by the second or third element in the cluster.  In the past I have used 1-D array sort and sorted by the first element of the cluster.  When I need to sort by the second, third, or fourth element of the cluster I just break down the cluster and rebuild it placing the desired sort element in the first position of the new cluster.  This works for simple tasks and clusters, but as the cluster gets more complicated this becomes a pain to do this.  There must be a cleaner way to sort by other elements within the original array of strict type def clusters.  Has anyone succeeded in doing this a different way?

    Hello,
    Here's the way I would do it...just create a new cluster array, where each cluster contains two elements...the unbundled item you want to sort by, and the cluster itself.  Then sort the new cluster array, then unbundle the sorted cluster array to get the original clusters (now sorted).  Here is a screenshot:
    There may be a better way, but this is the first thing I thought of.
    -D
    Message Edited by Darren on 03-16-200610:00 AM
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman
    Attachments:
    Sorted_cluster.jpg ‏30 KB

  • How to add all element of array?

    1-D array has N number of element .i want to sum all the element ,and the result is a number.
    can you give me some example?
    thanks.

    Just use the "Add Array Elements"-function located in the Numeric palette.
    Message Edited by becktho on 02-21-2006 12:58 PM
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    AddArrayElements.PNG ‏14 KB

  • Problems selecting elements from arrays

    I'm having difficulty selecting indexed elements from a array of nodes. I have seen this issues discussed in a number of threads but none address the specific issue which I have encountered.
    Previously in version 10.1.2 I constructed a XPath query and then used the BPEL getVariableData function to obtain the element I was after but this doesn't appear to be supported the same way in 10.1.3.1.
    I'm using the following expression
    bpws:getVariableData('VariableDBResult',bpws:getVariableData('xpath'))
    and when I try to compile I get the following error
    Error(243):
    [Error ORABPEL-10085]: invalid argument
    [Description]: in line 243 of "C:\....", the second argument "bpws:getVariableData("xpath")" for getVariableData is not a literal expression.
    [Potential fix]: Please correct the second argument, you might need to escape using single quote or &quot; to make it literal.
    I used the same code in 10.1.2 and it compiled fine.
    For reference the XPath is formed as follows
    concat('/ns3:Result/ns3:t/ns3:c/ns3:e[',bpws:getVariableData('loop'),']')
    But the error occurs at compile time not run time so I suspect the way the xpath is formed would not affect the compile
    I'm suspecting the problem has something to do with the fact that I'm using the function without the optional "pat name" the variable "VariableDBResult" is defined by a schema not a WSDL message type. I have compiled the Array sample 112 which used a part name and it works but in my case without the part name it fails.
    I attempted to cast the expression to a string and use a string variable, all to no avail.
    Any help or suggestions will be greatly appreciated.
    Regards
    Graeme

    Has anybody got around this issue...I searched the forums but allI could get it unresolved threads pointing to this problem
    getVariableData is not a literal expression
    Re: getVariableData is not a literal expression
    Literal function error
    Literal function error
    I want to mention that its a compile time issue and I am using Jdev 10.1.3.4

  • Remove blank element in array

    need help how to remove empty elements in an array?

    Hi jeyanthi,
    if you want to delete somthing from a txt file, you have also first to read the data, remove the part you want and to write the new data into the file. So i think you can do it with the array version. For example something like this:
    Mike
    Message Edited by MikeS81 on 06-09-2008 09:32 AM
    Attachments:
    Unbenannt1.PNG ‏6 KB

  • Store 1 Element in array

    Hi everyone I have a script to check to see if it can ping a list of IPs. If it cannot reach 1 it stores it in an array. The problem is if only 1 IP is stored in the array it treats each char as an element of that array. 
    $psr = $PSScriptRoot
    $a = Get-Content $psr\list.txt
    $machines = @()
    for($i=0;$i -lt $a.length;$i++){
    $key = $a[$i]
    $info = @()
    $info = -split $key
    $machines = $info[0]
    #Start-Sleep -Seconds 60
    for($j=0;$j -lt $machines.length;$j++){
    if(!(Test-Connection -ComputerName $machines[$j] -BufferSize 16 -Count 1 -ea 0 -quiet)){
    Write-Host $machines[$j]
    }else{
    Write-Host "All machines are awake"
    It happens in the second for loop list is just a snippet of the code. How can I write to host the full IP as 1 element?
    Thanks

    You have a couple of options.  You can use a foreach loop instead of a for loop, which is a special case in PowerShell.  Even though strings are Enumerable, PowerShell will not enumerate over the characters in the string unless you explicitly call
    its GetEnumerator() method.  Alternatively, you can put the @() operator around the call to Get-Content.  This is the array subexpression operator, and essentially tells PowerShell to convert the result to a single-element array if it is not
    already an array.
    $a = @(Get-Content $psr\list.txt)
    # or
    foreach ($key in $a)
    $info = -split $key
    $machines = $info[0]
    It looks like you may run into a similar issue in your second loop.  In general, foreach loops are preferred, unless you need to modify the contents of the array within the loop body or do some more complex stepping logic.

Maybe you are looking for