1d cluster array replace value in a 1d boolean array (without using Loop)
Hi ,
is there a way to replace the values (string , boolean) of a 1D array Cluster with value of 1D boolean array without using loop ?
Regards
Simone
Attachments:
111.png 75 KB
Replace Array Subset requires that the array elements are type compatible with the elements that you want to replace. That seems not the case in your example.
And the For Loop is anything but slow. How many billion elements do you expect your array to have to worry about performance of the for loop? With the type definition of your example even a ready made LabVIEW function would have to do internally a for loop too, since the boolean data inside the original array can not be in a continous memory area.
Maybe if you show us what you try to do with the for loop we can understand better what your concerns are. As it is from the front panel image alone it is really hard to understand what your imagined problem might be.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions
Similar Messages
-
Finding a minimum value in an array without using loops
I can find a minimum value in an array using a loop, but I am unsure of how to do it without any type of of loop
Here is what I have using a loop:
// This method searches for the minimum value in an array
public static int min(int a[]){
int min = a[0];
for(int i = 1; i < a.length; i++){
if(a[i] < min){
min = a;
return min;
How do I covert this to do the same thing, using no loops?
Thank you for replies
Edited by: kazmania on Feb 7, 2008 12:26 PMpublic class Test112 {
public int recurse(int[] x, int i, int n)
if (i==x.length-1) { return (x[i] < n) ? x[i] : n; }
n = (n < x[++i]) ? n : x;
return recurse(x, i, n);
public static void main(String[] args) {
int[] nums = {3, 1, 56, 2, 99, 34, 5, 78, -400, 2383, 201, -9, -450};
Test112 t = new Test112();
int min = t.recurse(nums, 0, nums[0]);
System.out.println(min); -
Finding the largest values of an array without using if condition
Hi,
I am trying to find the largest values of an array without using any if condition. Can any one tell me the solution for that..
ThanksI am trying to find the largest values of an arrayThe 'S' to values suggests that you want not only the largest one, but multiple ones among the largest ones. The best way, I think, is to sort the array, so that its largest values are grouped topgether. If the type is already Comparable, the following single line does the job:
Collections.sort(myArray);After this, the last values of the array are the largest ones.
Jerome. -
How do you create an array without using a shell on the FP?
I want to be able to read the status of front panel controls (value, control box selection, etc.) and save it to a file, as a "configuration" file -- then be able to load it and have all the controls set to the same states as were saved in the file. I was thinking an array would be a way to do this, as I have done that in VB. (Saving it as a text file, then reading lines back into the array when the file is read and point the control(s) values/states to the corresponding array element.
So how do I create an array of X dimensions without using a shell on the front panel? Or can someone suggest a better way to accomplish what I am after? (Datalogging doesn't allow for saving the status by a filename, so I
do not want to go that route.)Thanks so much m3nth! This definitely looks like what I was wanting... just not really knowing how to get there.
I'm not sure I follow all the icons. Is that an array (top left with 0 constant) in the top example? And if so, that gets back to part of my original question of how to create an array without using a shell on the FP. Do I follow your diagram correctly?
If I seem a tad green... well I am.
I hope you understand the LabVIEW environment and icons are still very new to me.
Also, I had a response from an NI app. engineer about this problem. He sent me a couple of VI's that he threw together approaching this by using Keys. (I still think you are pointing to the best solution.) I assume he wouldn't mind m
e posting his reply and the VI's for the sake of a good, thorough, Roundtable discussion. So here are his comments with VI's attached:
"I was implementing this exact functionality this morning for an application I'm working on. I only have five controls I want to save, but they are all of different data types. I simply wrote a key for each control, and read back that key on initialization. I simply passed in property node values to the save VI at the end, and passed the values out to property nodes at
the beginning. I've attached my initialize and save VI's for you to view. If you have so many controls that this would not be feasible, you may want to look into clustering the controls and saving the cluster as a datalog file.
Attachments:
Initialize_Settings.vi 55 KB
Save_Settings.vi 52 KB -
Creating an array without using "auto-indexing"
Hello,
it is terrible! I'm new in working with LV5.0 (Evaluation) and I can't
find any examples how to write data into an array without using the
function "auto-indexing" of the "WHILE" or "FOR"-loops..
The values do not appear all at the same time, so I can't use the
"create_array" function.
So I want to "collect" all occured values and then write them e.g. in a
file.
Did I miss anything in the description ???
Who can help me?
Thanks, CHZCHZ wrote in message news:[email protected]..
> Hello,
> it is terrible! I'm new in working with LV5.0 (Evaluation) and I can't
> find any examples how to write data into an array without using the
> function "auto-indexing" of the "WHILE" or "FOR"-loops..
> The values do not appear all at the same time, so I can't use the
> "create_array" function.
> So I want to "collect" all occured values and then write them e.g. in a
> file.
The "Create array" function can be configured to take arrays as well as
elements. You have to use a loop that iterates as often as necessary,
checking for new data. When it receives new data, it adds the new data to
the existing array. It's probably easier to attach a small example than to
describe it in more
detail.
[Attachment Array.zip, see below]
Attachments:
Array.zip 10 KB -
Hello
How to make labview program to get average value of 200 reading from multimeter (I using using loop) to read voltage from mulmeter but I like to get average value of all of 200 reding how can I do that?
Thanks
Wee
Solved!
Go to Solution.Another idea with less programming - take advantage of the "free" array that comes with a Chart - i.e. the History Data.
1) Wire your DMM data to a Chart. (You can set the chart to invisible if you don't plan on using it in the GUI).
2) Set the Chart History Length to 200 (right click on the chart, click on Chart History Length...)
3) On the block diagram, use the History Data Property Node, wire it to Mean.vi, and you're done.
Easiest running average ever.
Message Edited by Broken Arrow on 04-07-2010 11:36 AM
Richard
Attachments:
EasyAvg.jpg 8 KB -
I would like to make and insert elements to each index on an 1D array. but, I don't want to use loop. How can I input my data into 1D array increasing and indexing array? whenever We want to make a new array, Do We have to use a loop control?
To create an array, all you have to use is the Initialize Array function or just drop an array constant onto the diagram. You can then use either Replace Array Subset or Insert Into Array.
-
Convert array of clusters to cluster of arrays without for loop
Hi!
Here's a problem: I've got an array of clusters (array of messages). Each cluster consists of elements of different data types: double (time), cluster (parameters), char (station id), byte (message code). I know one cluster size and the array size. I need to draw a time graph. How can I convert the array of clusters to a cluster of arrays (array of time values, array of parameters clusters, arrays of chars and bytes).
I post this question because in my real array of clusters each cluster consists of 162 elements and some of them are clusters themselves, so I realy dont want to wire "for" loops as was advised in other topics.
Hope to get fresh ideas. Memory management? Type Cast? FlatternStrings and variants? Anything!
Thank you.Idea wrote:
Hi, everybody! Glad you read the post!
There is the cluster in the attachment. The application I make is a TCP client. The cluster is a message. Actually I get a string, find edges ("DIAG" - begin, "GAID" - end) and then I use "unflattern to string" for making the cluster. I cann't make another structure of the message - I didn't make the server. My client has a buffer of recieved messages. I need to plot graphs of different cluster elements for all messages in my buffer (for example the Time 1 element). If I use the for loop it would be too slow. The idea was to convert all buffer to a 2D array of U8 and then use type cast to get the cluster of arrays. Then it would be easy to take ane cluster element and send it to graph.
I didn't sucseed yet.
Idea.
What is your question about?
A) convert the string you get from I don't know where to the giant cluster, the red part in your message, or
B) making a graph out of some element from that giant cluster, who now is in an array, the blue part in your message.
The code you showed us looks a solution for question A but no loop is needed for this. So why bother about a loop that would be too slow here?
Also your code start from an array of U8, so where's the string?
If you could provide a string that needs conversion, we could try another way ... ...
Question B can easily be solved with a for loop and "unbundle by name". Don't know where you get the idea that a loop would be too slow
Open G library has a lot of VI's to retrieve specific elements from clusters, maybe one of those could help solve the problem. -
Replace Values for a Col under a Table using Replace Function in Sql Query
Hi all
I have a Custom Table by Name RESP_TABLE which stores the Responsibility Names under the Column RESPONSIBILITY.
The Sample Value for this col is as follows :
PF <CNTRY> Gl Analyst <CCY>.
This <CNTRY> Stands for Country Short Name
and <CCY> Stands for Currency.
The <CNTRY> & <CCY> should be passed as a parameter at the run time.
Based on the value given at the run time it should change accordingly.
For example
PF <CNTRY> Gl Analyst <CCY>
<CNTRY> Value passed at runtime : BE
<CCY> Value passed at runtime : CAD
So the resulting value should be as follows :
PF BE Gl Analyst CAD.
I had already used the query given below :
SELECT REPLACE(RESPONSIBILITY,'<CNTRY>','&MARKET') FROM RESP_TABLE.
This works fine for Country Code alone but not for currency.
I need both the Country Code and Currency Code to be changed to the respective values given at the runtime.
Could anybody please help me on this ?
Regards
Nakul Venkataraman.Hi Nakul,
Why not just adding another REPLACE to what you still have achieved? :)
Regards,
Guido -
Get the message attribute values in Orchestration without using property promotion
I have the following schema :
Now I want to get the values of FName,LName in orchestration without using any property promotion ?
PrakashThere are also multiple ways of creating the Xpath:
- Full path with namespaces - Rahul Madaan showed this one
- Full path without namespaces:
FName = xpath(InputMessage, "string(/*[local-name()='Root']/*[local-name()='IntField'])");
I think this method is handy if you have multiple schemas with similar structure but the namespace
changes. This is also easier to read and less prone to errors if there are any changes.
If you for example wanted the node #3, then it would be
FName = xpath(InputMessage, "string(/*[local-name()='Root']/*[local-name()='IntField'][3]/*[local-name()='IntSubField'])");
- Jump directly to the field/node you need (this one works for at least xml elements):
xpath(InputMessage, "string(//*[local-name()='IntField'])");
I find this useful when picking up key-values from the message, that can be available only once.
All the examples above are for elements. Since you are picking up value from an attribute, the actual structure
is
varFName = xpath(InputMessage,"string(/*[local-name()='StudentDetails']/*[local-name()='Student']/@*[local-name()='FName'])");
And to learn the rest of the possibilities of Xpath, like count, different types, more detailed selections
of the correct Node (Like example, I want only the one where FNAME = 'MyFName') You can try something like: http://social.technet.microsoft.com/wiki/contents/articles/6944.biztalk-orchestrations-xpath-survival-guide.aspx
Also get DanSharp XmlViewer. It will help you quite a bit when fine tuning the xpaths. -
How to convert imaq image to a 2D array without vision development module
Hi,
I'm looking for a way to convert an Imaq image into a regular picture (2D array) without using "Vision development module", nor saving it to a file (I need a refresh rate of about One frame per second).
any ideas?
thanks,
Gilad.Greetings,
If instead of attempting to acquire the image as the raw data as per the last example, are you looking for something then like the IMAQ Image to Array? I made some research and initially I believed this VI was part of the Development Module, but I was thinking of the Array to Image VI, which is why I did not bring it up earlier.
Finally, how exactly will you then be manipulating that array? Or will you simply be interested in displaying it?
Cordially;
Simon P.
National Instruments
Applications Engineer -
My situation is that I have an array of clusters on the front panel. Each element is used for a particular test setup, so if the array size is three, it means we have three identical test setups that can be used. The cluster contains two string controls and a button: 'device ID' string, 'start' button and 'status' string.
In order to keep the diagrams simple, I would like to use a reference to the array as input into a subvi. This subvi will then modify a particular element in the array (i.e. set the 'status' string).
The first problem I encounter is that I can not select an array element to write to by using the reference. I have tried setting the 'Selection s
tart[]' and 'Selection size[]' properties and then querying the 'Array element' to get the proper element.
If I do this, the VI always seems to write to the element which the user has selected (i.e. the element that contains the cursor) instead of the one I am trying to select. I also have not found any other possible use for the 'Selection' properties, so I wonder if I am doing something wrong.
Of course I can use the 'value' property to get all elements, and then use the replace array element with an index value, but this defeats the purpose of leaving all other elements untouched.
I had hoped to use this method specifically to avoid overwriting other array elements (such as happens with the replace array element) because the user might be modifying the second array element while I want to modify the first.
My current solution is to split the array into two arrays: one control and one indicator (I guess that's really how it should be done ;-) but I'd still like to know ho
w to change a single element in an array without affecting the others by using a reference in case I can use it elsewhere.> My situation is that I have an array of clusters on the front panel.
> Each element is used for a particular test setup, so if the array size
> is three, it means we have three identical test setups that can be
> used. The cluster contains two string controls and a button: 'device
> ID' string, 'start' button and 'status' string.
>
> In order to keep the diagrams simple, I would like to use a reference
> to the array as input into a subvi. This subvi will then modify a
> particular element in the array (i.e. set the 'status' string).
>
It isn't possible to get a reference to a particular element within an
array. There is only one reference to the one control that represents
all elements in the array.
While it may seem better to use references to update
an element within
an array, it shouldn't really be necessary, and it can also lead to
race conditions. If you write to an element that has the
possibility of the user changing, whether you write with a local, a
reference, or any other means, there is a race condition between the
diagram and the user. LV will help with this to a certain extent,
especially for controls that take awhile to edit like ones that use
the keyboard. In these cases, if the user has already started entering
text, it will not be overwritten by the new value unless the key focus
is taken away from the control first. It is similar when moving a slider
or other value changes using the mouse. LV will write to the other values,
but will not rip the slider out of the user's hand.
To completely avoid race conditions, you can split the array into user
fields and indicators that are located underneath them. Or, if some
controls act as both, you can do like Excel. You don't directly type
into the cell. You choose w
hich cell to edit, but you modify another
location. When the edit is completed, it is incorporated into the
display so that it is never lost.
Greg McKaskle -
How to build a cluster array dynamically from another cluster array?
I'm working on a problem where I seem to be getting lost in a sea of
possibilities, none of which strikes me as optimum. Here's what I need to do.
I've got an input array of clusters (ARR1). Each cluster contains the
following components: an integer (INT1), a ring variable (RING1), a boolean
(BOOL1) and a cluster which itself is simply a bunch of ring variables
(CLUST1) Now, I need to transform that into a set of clusters (CLUST3) each of
which contains an array of characters (CHARARY2), a copy of the ring variable
(RING2), a copy of the boolean variable (BOOL2) and a copy of the cluster
(CLUST2).
To build the CLUST3, I need to find all elements within ARR1 that have the
same unique combination of RING1 and BOOL1, and if BOOL1 is True, then RING1
in addition, build an array of all the INT1 values corresponding to each
unique combination above converted to character, and then bundle this array
plus the unique combination of the other variables into a new cluster. In
general I could have several such clusters.
So if I had the following array to start with:
Index INT1 RING1 BOOL1 CLUST1
0 3 1 F {Values1}
1 2 1 T {Values2}
2 4 0 F {Values1}
3 6 0 F {Values3}
4 1 2 T {Values2}
5 4 2 T {Values2}
6 3 0 T {Values3}
7 4 2 T {Values3}
I should end up with the following clusters:
CHARARY2 RING2 BOOL1 CLUST1
"3" 1 F Don't care
"2" 1 T {Values2}
"4","6" 0 F Don't care
"1","4" 2 T {Values2}
"3" 0 T {Values3}
"4" 2 T {Values3}
What methods would you suggest for accomplishing this easily and efficiently?
Alex Rast
[email protected]
[email protected]Tedious but not conceptually difficult.
ARR1 goes into a for loop, auto indexed on the FOR loop. The for loop has a
shift register which will be used to build the output array. Nested within
the for loop is another for loop, which the shift register array goes into,
again auto indexed, along with the element that has been auto-indexed from
ARR1. This for loop has a shift register, initialised with a boolean "true".
The inner loop compares the current element of ARR1 with the output array
and if an element in the output array is already present which matches the
input by your criteria, then the boolean register is set false; otherwise it
is left alone.
After the nested FOR loop you have a case fed from the boolean shift
register; if the boolean is true, the new element is unique and should be
added to the array. If it is false then a previous element has been found
making the present one redundant, and the array should be passed through
without adding the element.
In the true case, you simply unbundle the original element into its
components and build the new element, using "build array".
Notes for if the above is easy for you;
1) if handling lots of data then pre-initialise the shift register of your
outer loop with the same number of elements as your input array. Use
"Replace Array Subset" instead of "Build Array" to insert the current
element into the pre-allocated memory rather than having to create a new
array and copy all the current data across, which is what "Build Array" is
doing. Use "Array Subset" at the end to obtain a new array containing just
the elements you've used, removing the unused ones at the end.
2) Again for large datasets- the use of a while loop instead of the inner
for loop is more efficient since you can halt the while loop as soon as a
duplicate is found. With the described approach you have to go through the
whole array even if the first element turns out to be a duplicate- much
wasted computer time.
Alex Rast wrote in message
news:[email protected]...
> I'm working on a problem where I seem to be getting lost in a sea of
> possibilities, none of which strikes me as optimum. Here's what I need to
do.
>
> I've got an input array of clusters (ARR1). Each cluster contains the
> following components: an integer (INT1), a ring variable (RING1), a
boolean
> (BOOL1) and a cluster which itself is simply a bunch of ring variables
> (CLUST1) Now, I need to transform that into a set of clusters (CLUST3)
each of
> which contains an array of characters (CHARARY2), a copy of the ring
variable
> (RING2), a copy of the boolean variable (BOOL2) and a copy of the cluster
> (CLUST2).
>
> To build the CLUST3, I need to find all elements within ARR1 that have the
> same unique combination of RING1 and BOOL1, and if BOOL1 is True, then
RING1
> in addition, build an array of all the INT1 values corresponding to each
> unique combination above converted to character, and then bundle this
array
> plus the unique combination of the other variables into a new cluster. In
> general I could have several such clusters.
>
> So if I had the following array to start with:
>
> Index INT1 RING1 BOOL1 CLUST1
> ---------------------------------------------------
> 0 3 1 F {Values1}
> 1 2 1 T {Values2}
> 2 4 0 F {Values1}
> 3 6 0 F {Values3}
> 4 1 2 T {Values2}
> 5 4 2 T {Values2}
> 6 3 0 T {Values3}
> 7 4 2 T {Values3}
>
> I should end up with the following clusters:
>
> CHARARY2 RING2 BOOL1 CLUST1
> -----------------------------------------------------
> "3" 1 F Don't care
> "2" 1 T {Values2}
> "4","6" 0 F Don't care
> "1","4" 2 T {Values2}
> "3" 0 T {Values3}
> "4" 2 T {Values3}
>
> What methods would you suggest for accomplishing this easily and
efficiently?
>
> Alex Rast
> [email protected]
> [email protected] -
Scrollable cluster arrays as control, writing programmatically at the same time?
I would like to have a cluster array (just an example, you may suggest better solution), where each row (cluster-element) contains signal selection from combobox, and its value and unit.
I would like to have a signal list, where in each row, I can select which signal I want to show e.g. "motor speed", "motor torque", "motor power". And when signals are selected, the value of the
signals are automatically updated elsewhere. So basicly, I want to select which signals I monitor, and then watch them change over time. I use single cluster array because I want it to be scrollable. The problem is:
* let's say I have one row in the array. Then I add a row by editing the control in the GUI (now the array control has size 2).
* I have property node (write: array control -> value) to update the values and units in my software.
* I use array control output as the input in the subVI where I read my selections and write updated signal values.
* It can happen that I use that array control output when it still has size 1, and while I have added the second element, the software updates the control, and overwrites my new element addition.
So, I run into writing conflict. Only single user, just this problem. How should I avoid this?
(e.g. how can I know that user is not interacting with the control, so that I can update its value and unit fields)First suggestion is to post the code you have.
But that being said what you want to do can be done. I think the problem you are having is a race condition between the user and the software. Where the user chagnes the value and the software changes it back. I suggest reading the value of the control and replacing its value but keep the signal names the user entered, then write that back to the control.
Another suggestion is to have two separate arrays, one that is signal selection, and one is values. Then you only need to update the values table with the new data and the signal names never get overwritten. You'll likely want to couple the two arrays so when one index value changes the other changes with it. This can be done with an independent scrollbar control.
Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously. -
Set Colors of a part of a booelan cluster array
I put an example of a cluster boolean array. Now i a want that a certain part (see the red arae) has another color.
Not the colors as set by 1 or 0. And keep the rest of the array in the other (white) color.
I put the attached example ColorArray.vi (labVIEW2010).
Is that possible?
Kind regards, Ben Arts
Attachments:
ColorArray.vi 11 KBHi Ben,
simple rule in LabVIEW: in an array all elements share the same properties, they only differ in value!
So you cannot color some elements different to the other (using properties).
But:
You could make that array transparent (using the brush tool) and put it in front of an array of colorboxes.
Or you create an array of cluster of [value, colorbox], where the value is displayed in front of the colorbox.
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Maybe you are looking for
-
Hello , I am using PP-PI. The resource category is '001' machine and having std formulas 'sap001' for setup and sap002 for processing and other formula 'sap006' The recipe has setup time and processing time .When i run MRP the planned orders are crea
-
I can no longer download apps on my iPad. Can I download ios 5?
I'm not even sure what operating system I have but I can no longer update apps bc the ios requirement is too high....what can I do?
-
Hi all, I am developing a consignment tracking application with Application Express. So far the user can create new consignments and track existing ones. Now some of our customers wants to print vouchers. Because they are used to Crystal Reports they
-
For sap mdm do i need to know webdynpro abap or java
hi i want to learn sap mdm, then do i need to have knowledge in any of following languages? 1. webdynpro abap 2.webdynpro java 3. normal java( core java/j2ee ) 4. normal abap thanks akhil
-
When I try to set default font on my JMenuBar like this: javax.swing.UIManager.put("JMenuBar.font",new Font("Verdana",Font.PLAIN, 14)); nothing happens? Can someone help me with this.