How to replace cluster element in an array?

hi,
I have understood preferable choice is to initialise array first and replace elements in an array instead of inserting new element in an array e.g. in a while loop.
So I started to this evaluate since I have an application where I want to read lots of measurements from a txt file and display them in a XY graph. XY graph must show Y value and corresponding X value either red if it is out of range and in green if it is in range. I found a solution to do it with an array of clusters.
In attached example I have two different methdologies represented. My problem is that upper solution doesn't display content of all measurements. Can somebody tell me what I'm doing wrong ?
regards,
petri
Solved!
Go to Solution.
Attachments:
plot test 3.vi ‏19 KB

Petri wrote:
... using cluster with three elements was a method I found to put red and green dots in one XY graph, eg. Y=coordinateY, X(green)=NaN,X(red)=coordinateX. Perhaps there is a better way to display the data, but I couldn't find it.
That is an odd thing and makes little sense. Why three? four, five, etc are NOT supported, so what if you want more than one color? (in range, fail high, fail low?). For more detail see the discussion here.
In any case, reading all these values from a datafile and creating xy plots is trivial. I would recommend to use complex data. a single complex array will graph IM vs RE. For multiple plots, combine them using "build cluster array". No loops needed.
Here's a quick draft. Of course you need to decide if the data is in columns or rows, etc. so modify as needed.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
plot2XY.PNG ‏7 KB

Similar Messages

  • Change properties of a cluster element withing an array of clusters

    Hello all,
    I have an array of cluster that is shaped as a line with different display elements.
    A list or a tree wouldn't have made it, so I had to use a cluster and make a table.
    The problem is that I want to change not only the text but also the text color.
    Individually.
    I found this :
    http://www.ni.com/example/30904/en/
    But it change the property in all the clusters in the array, not just the one I need.
    Some people have the same problem :
    http://forums.ni.com/t5/LabVIEW/Reference-to-Array-of-Clusters-with-an-array-element/td-p/1006427
    http://forums.ni.com/t5/LabVIEW/Different-set-of-values-for-two-rings-in-an-array-of-clusters/m-p/10...
    http://forums.ni.com/t5/LabVIEW/array-of-clusters-get-references-to-all-the-clusters/td-p/1079456
    http://forums.ni.com/t5/LabVIEW/How-can-I-reference-the-properties-of-a-control-in-a-cluster-in/m-p/...
    http://forums.ni.com/t5/LabVIEW/Writing-only-to-certain-cluster-elements-in-an-array-by/m-p/2200728
    http://forums.ni.com/t5/LabVIEW/Update-Properties-Of-One-Control-In-An-Array/m-p/3015501
    http://forums.ni.com/t5/LabVIEW/Array-of-clusters-and-in-the-cluster-is-a-bar-meter-how-can-I/m-p/15...
    http://forums.ni.com/t5/LabVIEW/Property-node-of-a-control-inside-of-cluster-inside-an-array/m-p/946...
    Obviously, while in a list/table or tree you can change the property of an individual
    cell (font, color) you cannot do it within an array of cluster, by some sort of magic,
    the property of a cluster element (font, color) are all linked together, hence rendering
    the use of an array worthless.
    A possible hack is proprosed by using control masking, setting one visible and the
    other invisble, swapping their position, whatever. It's a hack you have to perform,
    hence add another code to maintain.
    Is that still the case or is there now a more official way to handle individual cluster
    properties, not just its data ? After all that's a common real-life example that should
    be handled by Labview. In my opinion.
    David Koch
    Solved!
    Go to Solution.

    altenbach wrote:
    One of the elements could be a 2D picture indicator of about the same size. You can write text in any color using picture functions.
    Here's what I had in mind. Seems to work just fine (I would fine-tune the font, picture border, etc. but this should get you started).
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ColorText.png ‏13 KB
    ColorText.vi ‏9 KB

  • How to delete an  element in an array...(simple way)

    hi,
    Newbie here... please help how to delete an element in an array list?
    there are alot of codes but they're complicated for a newbie like me..
    (simple codes would be better ..:) thank you...

    makk_88 wrote:
    since u want the simple method.....
    just overrite the position of the element that need to be deleted with the next element in the array..
    by doing this, element need to be deleted will not be accessibe..
    i think u got..what i'm saying.
    thnx..Mak,
    Say we wish to delete the second element of an array a[1]. Do you really believe that a[1] = a[2] somehow magically deletes a[1]? I really don't think so Tim.
    Two eggs, minus 1, equals two eggs? Interesting theory, but I think you're probably wrong.
    *@OP:* My advise is just use an ArrayList.
    Cheers. Keith.

  • How to show the elements of an array?

    How to show the elements of an array, when the array size changes every loop?
    It's possible to use node property?
    thanks
    Vicens
    Win XP/ LV7.1
    Attachments:
    show elements.PNG ‏184 KB

    Basically it is (at least in LV8.0). There is a property "Number of Rows" which sets the number of visible rows. If your 1D array is placed horizontally, use "Number of Columns".
    Using LV8.0
    Don't be afraid to rate a good answer...

  • Why is it so difficult to replace one element in an array?

    Maybe I am missing something but it seems overly complicated to replace one element in an array.
    I have a 3 Col 15 row array. Each column represents a board of IO and each row is a specic IO location on the board.
    I have 4 arrays each that vary in lenth that represent 4 different IO types (i.e. AO, DO, AI, DI). I want to people to write them one by one in order to allow a map to be stored as a constant. In that way if the end user decides to change some of the IO around on me it is easy.
    However I am not seeing an easy way to write to one specific element. Replace supset will only allow me to call out either row or column.. not both (this makes no sence to me).
    I hope someone can help.
    Thank you.

    You can certainly replace a single element in a 2D array and specify row and column. Attach the code you are having problems with.
    Attachments:
    Replace Element.PNG ‏2 KB

  • How to insert 1 element in 2D array?

    There is an example of how to replace element in 2D array, but I would like to insert (not replace), I use the insert element. it does not work for 2 D array.
    Attachments:
    find_and_map_defect_to_image736X554.vi ‏46 KB

    You need to tell more about what you want done. What exactly does it mean
    to insert into a 2D array? Are you inserting into the row or column or
    both? By that I mean to ask what parts of the array get their indices
    incremented. Then what should happen at the endpoints? If you insert a
    point into one row then that row will have one more element than the others.
    Should the last element in that row be lost or should the other rows get a
    zero appended?
    "trout00" wrote in message
    news:[email protected]..
    > There is an example of how to replace element in 2D array, but I would
    > like to insert (not replace), I use the insert element. it does not
    > work for 2 D array.

  • How to average each element in an array

    I have data from a Gage Card that I would like to average.  I am tuning a laser over a 50 mA range and for each 1mA increment in current, I am taking 100 scans.  Each scan consisting of about 200 points.  I cannot average more than 10 shots using the Gagecard so I would like to capture 100 scans, and average them to reduce noise.  Currently, I have my capture vi inside of a for loop which repeats 100 times and each scan writes to a file, but I would like ony 1 scan (the lower noise averaged one) per current increment.  
    How can I average each element of 100 arrays and output this to an array?
    Thanks for the help 

    It sounds like you want to average element 0 across 100 arrays and make that element 0 of the new averaged array.  Then average element 1 across 100 arrays and make that element 1 of the new array ...   ?????
    How are you working with your 100 1-D arrays now? 
    What you should do is make a 2-D array where one dimension is 100 (for the number of individual arrays) and the other dimension is how many elements are in those 100 1-D arrays.  Then you can use for loops with auto indexing to break the 2-D array down into each row or column, do the average of that array, and autoindex on the other side to build back up into the new 1-D array of averages.  You may need to to a transpose array going into your for loop in case the arrays are indexed in the wrong direction.
    Message Edited by Ravens Fan on 01-21-2008 04:26 PM
    Attachments:
    Example_BD.png ‏6 KB

  • How to find the elements of an array

    I want to find the number of elements in an array, and I can't find the tutorial that shows how to find it. If anyone could point me in the right direction, it would be greatly appreciated.

    warnerja wrote:
    flounder wrote:
    DrLaszloJamf wrote:
    You mean x.length?<pbs>
    Depends upon your interpretation of "number of elements in the array"
    int[] numbers = new int[10];
    numbers[0] = 42;
    numbers[1] = 666;Number of elements in the array is 2 not 10.
    </pbs>If you used something other than a primitive type for the array element type you could have a case. A value of integer zero for the other elements is still a value, so there are indeed 10 elements there.Even if it were not primitive, every element would have a value. That value would either be null or a reference.

  • Can I replace several elements of an array within one time? The number of elements are not fixed

    Hi all,
    I want to replace some elements of a 2D array, but the number of elements are not known beforehand. I dont want to do it with a loop, which may slow down the speed, and the update of elements will not happen simultaneously.  The indexes of elements to be updated are not continuous. I wonder if there is a way to do that efficiently? Do I have to programme it in LabWindows/CVI? Thank you.
    Best wishes,
    Bo
    My blog Let's LabVIEW.

    Use the replace elements function. For non-continuous replacements  of of multiple elements you would nee to iterate at least the number of continous pieces.
    For example:
    1,2,3,4,5,6,7,8,9
    Replace elements 1,2,5,6,8
    You would need 3 iterations in which you can replace (1,2), (5,6) and (8).
    Regards,
    André
    Using whatever version of LV the customer requires. (LV5.1-LV2012) (www.carya.nl)

  • How to add new elements in an array of Objects of Type Figure??

    I have a Figure class which has many attributes(variables). Then I create an array of Figures for example
    Figs[] figures = new Figure[18];
    Later I need to add new Figures to this array at different positions. In my case I have to use the same array.
    Is there any way so I can add new Figure elements to this array??
    If u have an answer to this question, please share with me.
    Thanks
    Amit

    There are many ways to solve this problem, including creating new arrays as needed, and using System.arraycopy() to move things around. However, the best way is to use ArrayList, as discussed above.
    What you cannot do is use toArray() and cast back to String[]. Object[] is not a subclass of String[], even if all of the objects in the Object[] are Strings!
    There are two ways to get around this. Create a String[] and copy the Object[] into it with System.arraycopy, or the easy way, which is to use the toArray(Object[]) method. It allows you to specify by example the array class you wish returned. If the array is large enough, it will populate the array directly, otherwise it will create a new one of the same base class. That means any of the following approaches will work, the final decision is mostly a matter of style:
        // create a zero length array to pass as an exemplar
        public final static String STRING_ARRAY_TYPE[]  new String[0];
        String s[] = (String[]) a.toArray(STRING_ARRAY_TYPE);Or:
        String t[] = new String[a.size()];
        a.toArray(t);Or:
        String t[] = a.toArray(new String[a.size()]);;I prefer the first approach generally, and it avoids any race conditions between the evaluation of the ArrayList size and the toArray; however, since ArrayList methods are not synchronized, you probably should do some synchronizing of your own.
    Hope this helps.

  • How to pick random element in 2D array

    This is the contents of my constructor. How is the best way to pick a random element in a 8x8 array and assign it "Q"?
         public DancingQueen()
              board = new char [BOARD_SIZE][BOARD_SIZE];
              for (int i = 0; i < board.length; i++)
                   for (int j = 0; j < board.length; j++)
                        board[i][j] = SPACE;
                   Random generator = new Random();
                   int r = generator.nextInt(8);
                   int c = generator.nextInt(8);     
                   board[r][c] = "Q";

    Better make that 'Q' instead of "Q". The rest is fine though.
    kind regards,
    Jos

  • How to increment an element in an array and put it back in the same array?

    I have an array of values generated by another part of my program. My goal is to count the number of occurences for each integer value in the array and put these values in a new array. This new array will be a histogram of the input array. My approach is to do auto-indexing with a for loop. In the loop I use a "index array" to get the current value of the histogram array and a "replace array subset" to update the array element with "current+1". The problem is that when I wire the output of the "replace array subset" VI back to its input, I get a wire error. I guess I cannot wire it like that, but what should I do? Is there a completely different approach to do this that
    is more elegant?
    Thanks for your help!
    Benoit

    Hi Benoit,
    I believe the thing that's missing is a shift register.
    Right-click on the edge of your "For loop" and select add shift register.
    Wire an initialized array to the shift register left terminal before entering the "for loop". Wire from this same terminal (inside the loop) as the source of the info used in your "index array" and replace array. The results of these two operations (just the way you are doing it now) gets wired to the "right terminal" of the shift register (inside the loop).
    What ever you stuff into the right terminal, gets returned via the left terminal on the next iteration of the loop. When the loop is done, your final array of counts can be accessed by wiring from the "right terminal" (outside the loop).
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How can I supply elements of an array to the New-ADUser Class. Or can I do this another way?

    Hi, I want to write a function to create a new user, and I want to keep it as simple as possible.
    For example, I want to be able to call the function like.
    CreateNewUser John Doe
    The function itself will need to pass the value of the name, in this example John Doe into an array. And then I want to be able to reference that array for everything else.
    e.g
    Function CreateNewUser($fname,$lname)
    [string[]]]$objName = $fname,$lname
    New-ADUser -name $objname -givenname $objname[0] -surname $objname[1]
    I hope you get the idea. Is this possible, am I doing it right, and is there a better way of doing this?
    Thanks

    If you are just trying to make it look a bit cleaner you can use splatting so new-aduser isn't incredibly long...here is an example.
    $Params = @{
    Name = $DisplayName
    SamAccountName = $SamAccountName
    UserPrincipalName = $UserPrincipalName
    GivenName = $GivenName
    Surname = $Surname
    DisplayName = $DisplayName
    Path = $Path
    AccountPassword = $Password
    Enabled = $True
    ChangePasswordAtLogon = $True
    HomeDirectory = $HomeDirectory
    ScriptPath = $ScriptPath
    EmployeeID = $EmployeeID
    Department = $Department
    Division = $Division
    New-ADUser @Params
    The splatting will definitely help, but I think what the OP is really looking for is a wrapper to make the command line really simple. I have a function I use called Copy-AdUser that does several things internally to support our business needs. The command
    line is simple:
    Copy-AdUser -Instance gwashing -GivenName Abraham -SurName Lincoln -Title President -Location 'White House'
    Now you may not need to copy an existing user, but the ideas are the same. You can accept basic information about the user as parameter values and then in the guts of the function you can calculate all the other attributes, group membership, etc. The function
    looks something like this:
    Function Copy-ADUser {
    #.SYNOPSIS
    # Creates new Active Directory user based on attributes #and group membership of an existing user
    #.DESCRIPTION
    # Creates an Active Directory user based on an existing #user's group membership and Organizational Unit.
    # Requires that the MS Active Directory module is loaded.
    #.EXAMPLE
    # Copy-AdUser -Instance gwashing -GivenName Abraham #-SurName Lincoln -Title "President" -Location "White House"
    [CmdletBinding()]
    Param
    # Template user. Copies parent OU and group membership
    [Parameter(Mandatory=$true,Position=0)]
    $Instance,
    [Parameter(Mandatory=$True,Position=1)]
    [String]$GivenName,
    [Parameter(Mandatory=$True,Position=2)]
    [String]$SurName,
    [Parameter(Mandatory=$True,Position=3)]
    [String]$Title,
    # building code for primary location
    [Parameter(Mandatory=$True,Position=4)]
    [String]$Location,
    # Optional. Department or division (IT, HR, etc.)
    [Parameter(Mandatory=$False)]
    [String]$Department,
    # Optionally specify the SAMAccountName if it needs to be different than the standard formula
    [Parameter(Mandatory=$False)]
    [string]$SamAccountName = ($GivenName.tolower().substring(0,1) +
    $SurName.ToLower().Substring(0, [System.Math]::Min(7, $SurName.Length))),
    # Optionally specify the UPN prefix if it needs to be different.
    # This will be used for email addresses and the UPN
    [Parameter(Mandatory=$False)]
    [string]$UPNPrefix = ($GivenName.tolower() + '.' + $SurName.tolower())
    # company specific variables
    $EmailDomain = '@domain.com'
    $HomeFolderPath = '\\Server\Share'
    # calculate stuff
    $Instance = Get-ADUser $Instance -Properties *
    $OU = $Instance |
    Select-Object @{n='ParentContainer';e={$_.DistinguishedName -replace "CN=$($_.cn),",''}}
    $ADGroups = $Instance.MemberOf
    $UserPrincipalName = ($UPNPrefix + $EmailDomain)
    $FirstLast = "$GivenName $SurName"
    $Proxies = "SMTP:$UserPrincipalName"
    $HomeFolder = "$HomeFolderPath\$($SAMAccountName.ToUpper())"
    # Create the Active Directory User
    If(Get-ADUser -Filter {SAMAccountName -eq $SAMAccountName})
    Write-Warning "User with name $SamAccountName already exists!
    Please try again and specify unique values for the -samaccountname and -UPNPrefix parameters."
    Return
    Else
    $Attributes = @{
    Name = $FirstLast
    GivenName = $GivenName
    SurName = $SurName
    UserPrincipalName = $UserPrincipalName
    SAMAccountname = $SAMAccountName
    AccountPassword = (Read-host -assecurestring 'Enter Password')
    DisplayName = $FirstLast
    Description = "$Location $Title"
    EmailAddress = $UserPrincipalName
    homedrive = 'H:'
    HomeDirectory = $HomeFolder
    ScriptPath = 'login.bat'
    Title = $Title
    Company = $Location
    Department = $Department
    path = $OU.ParentContainer
    Enabled = $True
    OtherAttributes = @{proxyaddresses=$Proxies}
    New-Aduser @Attributes
    # Add User to the same groups as the UserToCopy
    $ADGroups |
    ForEach-Object {
    Add-ADGroupMember -Identity $_ -Members $SAMAccountName
    # Create home folder and set permissions
    Do
    Set-FolderPermission -Path $HomeFolder -User $SamAccountName -Permission 'Fullcontrol' -ErrorAction SilentlyContinue
    Until
    (Get-ACL $Homefolder).Access.IdentityReference -like "*$SamAccountName*"
    Please note this is probably not ready for you to use. You can change any of the internal logic to support naming schemes and paths that your organization uses. Also, there is a call to a function at the bottom that creates a home folder and sets permissions
    on that folder. I haven't included that function so this part will error out.

  • How to change cluster-elements used in subvi´s automatically?

    Hello,
    I have a Array of Clusters and a lot of SubVIs using this Cluster. If I change the Cluster ( f.e. thorugh adding a new INT-value to it), I need to go in all of my SubVIs and also do the same changes there. There must be an easier way to do this, but I was not able to find it out. I tried thorugh refernece, but it didnt work :-(    I was also not able to find a solution here in this forum.
    Can somebody help pls?
    LabVIEW 2011
    Solved!
    Go to Solution.

    Serdj,
    I am not sure if this is your problem, but have you tried type defining the cluster?
    Look here http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/creating_type_defs/
    regards,
    aCe
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • How to replace XML elements using java

    I have been usint SAX 2.0 and DOM Level 2 api's to represent XML documents, which i parse with apache's Xerces parser... I am trying to delete certain elements and replace them with others, but none of the api's allow this the closes i have come is replacing attributes of elements....

    Answered in crosspost.
    http://forum.java.sun.com/thread.jspa?threadID=638156

Maybe you are looking for

  • Creating adf-Faces portlets without using IFrame

    Is there a way we can create portlets with adf-faces that will display inline instead of IFrame? I have been experimenting with portlets creation and the only time the portlet will be rendered inline is when you choose the "generate JSP" at step 3 of

  • How to create stored procedure directely in RPD

    Hi Gurus, I am trying to create stored procedure directly in physical table in rpd level in OBIEE.for this one i have gone through below website. http://obiee101.blogspot.com/2011/01/obiee-using-mssql-stored-procedure-as.html in that blog they mentio

  • I forgot my email and passowrd for i cloud, how do I recover them

    Hello , ther is one friend he forgot he is i cloud ( email and password ) how he can recover them ??

  • Error 1638

    Hello, I unstalled skype and deleted everything skype related a few weeks ago. Today I tried to install skype again but I got error 1638. I'd be very grateful if any could help me. Display: Installing Skype failed: code 1638 Another version of this p

  • Aperture batch file rename: remove dashes from date?

    Just wondering if it is possible to change the format of the date from YYYY-MM-DD to YYYYMMDD when you rename files as they are imported into Aperture 3? I In Aperture 3, the date format used includes dashes. I would like to have the file renamed wit