Building an array of difference values

Dear Forum Members,
With reference to the attached LabVIEW 2010 Student Edition file....
From the incoming data via the .csv 'Read From Spreadsheet' I want to display an array of the difference between the n and n-1 data value i.e. if the data set is 10, 20, 25, 35, 50 then the difference will be 10, 5, 10, 15.
I have used the 'Index Array' function to extract the n and n-1 data values (using the 'Simulation Time' function as the Index Row incrementer) however I cannot find the way to build an array of these difference values and display them in the Front Panel i.e.
10
5
10
15
This will no doubt be a trivial issue for those more experienced LabVIEW programmers.  Any advice or assistance will be gratefully received.
Kind regards,
Solved!
Go to Solution.
Attachments:
Plant_Simulator (04-05-2013).vi ‏158 KB

I'll explain what I want to do again for clarity....
I have a simple spreadsheet file (in .csv format) that contains one (1) column of data x 800 rows (thats 800 elements).  I read the data into LabVIEW via the 'Read from Spreadsheet' function (I have already established this).  I then want to make an array that is the difference beween the n and n-1 data value.  Hence if the data set is 10, 20, 25, 50... then the difference will be 10, 5, 25..
I want to display the difference array to screen in an indicator that shows all the difference values in one (1) column x 799 rows.  Hopefully that explains what I want to achieve.
I tried the suggestion with the loop however there were multiple errors when this was attempted.  I cannot place the loop within the simulation frame (it doesn't allow it) hence its outside.
Please excuse my inexperience concerning the array order(s), I find LabVIEW to be particularly unfriendly in this respect and its the source of much of my frustration and pain whenever I'm using LabVIEW to implement anything.
Regards,

Similar Messages

  • Efficientl​y building an array of increasing values for a graph

    I need to build an array of values increasing by 3E-8.  Initializing an array and changing each value in a while loop works fine, but it is terribly slow.  Is there a better (faster) way of building an array of increasing values like this?

    Thanks for the suggestion, it looks like that could do what I'm looking for.  A kind tech solved the problem for me by phone -- I knew it was reading and writing the entire 100,000 element matrix to memory at each step, but I couldn't figure out how to get it to stop.  A shift register brought the run time from over 2 minutes to under 1 second.
    Thanks again for responding!
    Message Edited by Deamiter on 11-07-2006 06:46 PM

  • Build an array with 2 values assigned to 1 dimension

    I am wanting to build a 1D array where two values are assigned to each dimension.  For example:
    Index 0 would have a 1 and 4 assigned to it
    Index 1 would have a 2 and 3 assigned to it
    Index 2 would have a 0 and 1 assigned to it.
    Then I can unbundle this arrayand grab the two values for index 0, index 1, etc....  I want to put this array inside a typedef control.  Is this possible?
    Solved!
    Go to Solution.

    Thanks for the replies.  I considered using a cluster and had the typedef control modified to include the cluster.  I may just go back to this method if this is the simplest for the code I am modifiing.
    A 2D array assigns two values i.e. row and column to one number.  I need it the other way around.
    Here is what I am trying to do.  I need to control a rotary valve.  I am using compact filedpoint to control the rotary valve.  The valve requires a pulse (1 then 0) for the rotary valve to move 1 position. If the valve is on channel 1 of the fieldpoint module and I want it to turn to position 2, the I send two pulses to channel 1. 
    My thinking is I will have two values associated per rotary valve... a channel and a pulse value. So for example, valve 0 has a Boolean and a numeric value assigned to it in an array. Although, it doesn't have to be a boolean and a numeric.  it could be 2 numeric values for simplicity.
    I hope this makes sense because without knowing this posting a VI or image is useless.  Its the chicken before the egg thing. :-)

  • Build Array and Output Values to Text or Excel File

    I know this is a simple question but I need some help. I'm reading a DC voltage in LabVIEW a while loop. I want to store all the read values into an array and export that array as an text or Excel file. I had a VI that I build before for this but I cannot seem to find it and I can't remember how I did it before. Any help is appreciated. I think I can do the exporting part but I do help with building the array (storing all the data values).

    I run into a problem while using the "Write to Text File Function". Initially I took about 60 measurements and wrote to a text file. That works but I increased the amount of measurements to be taken to 600 and when I did that the output in the text file are all Chinese letters (or that's what it seems like). Is this because I'm writing too much data?
    When I use the "Write To Spreadsheet File VI" to write the measurments it works fine for the 600 measurements. The problem with this is I cannot insert any text. Using the "Write to Text File Function" I inserted some text before the measurements and "end of lines", to format the data. Attached is a screenshot of my VI.
    Attachments:
    measurements.PNG ‏45 KB

  • How to build a array with collected data

    Hi,
    I have collected data from serial port with VISA. Now I want to build a array with 100 date points. Should I connect VISA Read with Build Array directly? How to do it?
    PS: All of them are in a While Structure.
    Thank you!

    An inefficient way to create the array is to use the build array and a shift register as shown below. It's more effecient in terms of memory management to create the array and then use the replace array subset as shown in the other image. Of course, if you don't need the array inside the loop, just wire the value out of the while loop and on the exit tunnel, right click and select 'Enable Indexing'.
    Message Edited by Dennis Knutson on 07-03-2007 10:25 PM
    Message Edited by Dennis Knutson on 07-03-2007 10:26 PM
    Attachments:
    Crude Build Array.PNG ‏4 KB
    Better Build Array.PNG ‏6 KB

  • How to build a array with high sampling rates 1K

    Hi All:
    Now I am trying to develop a project with CRio.
    But I am not sure how to build a array with high sampling rates signal, like >1K. (Sigle-point data)
    Before, I would like to use "Build Arrary" and "Shift Register" to build a arrary, but I found it is not working for high sampling rates.
    Is there anyother good way to build a data arrary for high sampling rates??
    Thanks
    Attachments:
    Building_Array_high_rates.JPG ‏120 KB

    Can't give a sample of the FPGA right now but here is a sample bit of RT code I recently used. I am acquiring data at 51,200 samples every second. I put the data in a FIFO on the FPGA side, then I read from that FIFO on the RT side and insert the data into a pre-initialized array using "Replace Array subset" NOT "Insert into array". I keep a count of the data I have read/inserted, and once I am at 51,200 samples, I know I have 1 full second of data. At this point, I add it to a queue which sends it to another loop to be processed. Also, I don't use the new index terminal in my subVI because I know I am always adding 6400 elements so I can just multiply my counter by 6400, but if you use the method described further down below , you will want to use the "new index" to return a value because you may not always read the same number of elements using that method.
    The reason I use a timeout of 0 and a wait until next ms multiple is because if you use a timeout wired to the FIFO read node, it spins a loop in the background that polls for data, which rails your processor. Depending on what type of acquisition you are doing, you can also use the method of reading 0 elements, then using the "elements remaining" variable, to wire up another node as is shown below. This was not an option for me because of my programs architecture and needing chunks of 1 second data. Had I used this method it would have overcomplicated things if I read more elements then I had available in my 51,200 buffer.
    Let me knwo if you have more qeustions
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    RT.PNG ‏36 KB
    FIFO read.PNG ‏4 KB

  • Issue with building an array from a cfhttp request result.

    Here is what I am trying to do. Retrieve a bunch of results from a  REST request. Run a query to see if I should be excluding any of the xmltext entries coming back from the rest request. Build an array of the REST xmltext entries except the entries in the cfquery.
    I have it all workign except building the array minus the entries that came back in the cfquery. Here is my code so far.
    <cfquery name="getqueue" datasource="#application.settings.dsn#">
    select * from friends
    where Deactivatedate < #DATEADD('d', 1, CreateODBCDateTime(now()))#
    </cfquery>
    <cfoutput query = "getqueue">
    <cfhttp  blah blah>
    <cfset nodes_parse = XmlParse(CFHTTP.FileContent)>
    <cfset Nodes = xmlSearch(nodes_parse,'friends/friend/date/activedate/')>
    <cfset roleArray = ArrayNew(1)>
    <cfloop from="1" to="#arraylen(Nodes)#" index="i">
       <cfset NodeXML = xmlparse(Nodes[i])>
    <cfset ArrayAppend(roleArray, '[sel_members][]=#NodeXML.activedate.xmlText#&')>
    </cfloop>
    </cfoutput>
    My issue is down in the loop where I do the arrayappend. How would I build an array of values coming back from the cfhttp request but not include any of them if they match up with anything coming back from the getqueue query?

    What about the obvious? Namely,
    <cfif value_from_getqueue IS NOT value_from_cfhttp_request>
    <cfset arrayAppend()>
    </cfif>

  • Building an array to a specified format..

    I'm trying to build an array that follows a specified output format. The user inputs columns & rows e.g. C x R...amd the the output should read
    C1 C2 C3 C4.....
    R1 V V V V....
    R2 V V V V ...
    Where each V is not a constant, but a user inputed value. Sorta like a matrix in appearance.
    Any ideas??

    You can use a table control and use a property node to set the number of rows and columns. But that just sets the number of rows and columns which are visible. The user can navigate to additional rows and columns.
    You could create an event structure to keep the user within the specified bounds. You could also remove the scrollbars (right-click on table, goto Visible Items, the deselect Horizontal Scrollbar and Vertical Scrollbar).

  • Best way to create an array of bound values (to the resourceManager for example)

    What's the best practice for creating an array (array collection) where each element is bound to another value?
    An example would be an array of error strings that are used by an application.  Each string needs to change as the resource manager changes.
    Passing a list of strings to a list control is another example.  These should get localized as well.

    hobby1 wrote:
    Crossrulz, I was planning on handling it like this: 
    I have a total of 17 element I need to build an array from.  Each case would include another element to be written to the array.  Is this the correct way to handle this?
    Thats one way to do it.  Not nearly as efficient as using the Build Array, but it will work.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Methods to build an array inside a For Loop.

    Let me introduce to you my nested For Loops:  
    They output a 2D boolean array depending on two 1D boolean arrays of different lengths.  This is all well and good however, in another part of my program, I want this to be a 1D array instead.
    Idea #1:
    "I'll just reshape the array at the end. Simples!"
    Idea #2:
    "Hang on, why am I using three primitives outside the loop when I can use just one inside it along with a shift register?"
    Idea #2.5:
    "Oh, wait... I remember reading somewhere about continuously building an array (with concatenate inputs) inside a loop being a bad thing and quite slow. Let me test this."
    Spoiler (Highlight to read)
    Idea #3:
    "Umm... okay, so actually the second way is faster.  I think if I initialize the shift register first then replace subsets of the array, that might also be better."
    Spoiler (Highlight to read)
    Idea #4:
    "Yep - seems much better. (Something to do with LabVIEW not having to constantly allocate more memory on every iteration of the loop)  Looking at this closer, I don't actually need the inner For Loop because of the way I'm handling the arrays.  Try again...!"
    Spoiler (Highlight to read)
    Conclusion(?) #1:
    "Well I seem to have arrived at something that looks messier, but executes about 6x faster than my initial idea. That said, the difference rapidly increases as the input arrays get much bigger (becoming orders of magnitude different)."
    Is this the most efficient way of doing what I want?  Or is there something even better (and works in LV 8.5)?
    Never say "Oops." Always say "Ah, interesting!"

    Thank you both for the feedback.  It never occurred for me to recheck the logic after I'd initially extracted the nested For Loops, but the AND gate output is obviously the same now that it's been pointed out!
    Continuing on with Idea #4, I replaced the Select with an AND then compared the times.  (also meant I didn't have to initialize one of the arrays anymore)
    Spoiler (Highlight to read)
    It appears that the AND gate was slower but then I tried with different sizes of initial arrays and in one case, the timings were 'reversed'.
    This only happened when the top array (the one that is fed into the AND gate whole) was reduced to a length in the region of 5 elements long.
    Spoiler (Highlight to read)
    Why does this happen?  Is it something to do with the AND gate possibly being optimised for single element operations so smaller arrays are handled better...?
    Never say "Oops." Always say "Ah, interesting!"

  • Help me for build a array as follows

    Hi. I need build a array, with the number 10 in all positions of array. For example, if array is of size 10x10, the number 10 must appear in the 100 positions of array. But I need that the number  go storing in array  as follows: That store the number 10 in all row 1 of left to right, in row 2 of right to left and so on. I attached my VI, but i have a problem, the program make well the sequence but the number 10 no storing  in some positions, this positions is inthe extrems of some row,i think that i need to maintain the number of column for two cicles, buy i don't know very....Help me.!!...Thanks!! 
    Solved!
    Go to Solution.
    Attachments:
    Fotos_ejeX.vi ‏10 KB

    You said you want your array to be 10x 10, but you initialized it to only 9 x 9.
    Pay attention to where you increment your index.  You are incrementing your index before you replace array subset.  So on iteration 0, you wind up replacing at index 1 and completely missed index 0.  Increment at the end of the loop after replacing the element, not before replacing the element.
    I don't understand the comparisons to 15 and 8.  That seems like odd comparisons when you would be looking at a range of 0 to 9.  Something seems very awkward about comparing to those two numbers, and the use of 3 shift registers to track values when you are only incrementing two indices.
    Yes you don't want to increment or decrement your index on the column in the iteration where you are also incrementing a row.  So work that into your logic.
    You probably want to stop your while loop when you hit stop OR you've reached the end of your replacements.
    I would consider making two For Loops, one that iterates for rows, the inside one iterates for columns.  Shift registers on both to maintain the array.  Then use the i value of the inner loop to replace your element when you are in even rows, or the 9-i element when you are in odd rows.
    Since your indices are integer values, you should be using the blue integer datatype rather than orange floating point wires.

  • Fill array with Hue values

    Trying to build (simple) color palette, but keep getting ArrayIndexOutOfBoundsException: 0 when trying to fill the array with Hue values (Saturation and Brightness remain 100%):
    private Color[] hsb = new Color[numberOfCircles];
    float h=0;
    float raise=(1.f/numberOfCircles);
    for (int i=0; i<stKrogcev; i++) {
        hsb=Color.getHSBColor(h,1.0f,1.0f); //getHSBColor: "Creates a Color object based on the specified values for the HSB color model."
    h+=raise;
    }What am I doing wrong?
    What other way could you fill array (Color, int, float, ...) with Hue values?
    This is what I have thus far (only colors missing; not sure whether Sun supports images):  [http://www.shrani.si/f/1G/uM/v29MKIC/palette.jpg]. First three columns in the right-hand table are awaiting RGB values respectively, the last column gets Hue value.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    pbrockway2, numberOfCircles (or stKrogcev ) is an int, and is NOT zero. That Color[] hsb is zero.
    import javax.swing.*;
    import java.awt.*;
    public class BarvnaPaleta {
         public static void main (String[] args) {
              System.out.print("Stevilo krogcev: ");
              int n = BranjePodatkov.preberiInt(); // BranjePodatkov: just some custom class for reading input
              Okno o = new Okno(n);
              o.setVisible(true);
    class Okno extends JFrame {
         RisalnaPlosca risalna;
         public Okno(int n) {
              setTitle("Barvna Paleta");
              setSize(1200,900);
              setLocation(0,0);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              risalna = new RisalnaPlosca(n);
              add(risalna);
    class RisalnaPlosca extends JPanel {
         private final int ROB = 300;     
         int     stKrogcev;
         private int izhX, izhY;     
         private int     r1;
         private int     sirina = 60;     
         private int     visina = 20;     
         private double x, y, r2, r3;     
         private double vmesniKot;
         private double polovicaVmesnegaKota;
         //the much needed color arrays
         public Color[] hsb = new Color[stKrogcev];     
         private String[] red = new String[stKrogcev];     
         private String[] green = new String[stKrogcev];     
         private String[] blue = new String[stKrogcev];     
         public RisalnaPlosca(int n) { //constructor     
              stKrogcev = n;
              setBackground(Color.white);
         public void paintComponent(Graphics g) {
              super.paintComponent(g);
              izhX = getWidth()/2 -r1;
              izhY = getHeight()/2 -r1;          
              vmesniKot=(2*Math.PI/stKrogcev);
              polovicaVmesnegaKota=(vmesniKot)/2;          
              r1=getHeight();
              r3=(r1*Math.sin(polovicaVmesnegaKota))/(1+Math.sin(polovicaVmesnegaKota));
              r2=r1-r3;                    
              narisiKrog(g);
              napolniHSB(g); //  LINE 53
              narisiKrogce(g);
         private void narisiKrog(Graphics g) { //draw the BIG Circle
              g.setColor(Color.BLACK);
              g.drawOval(0, 0, r1, r1);
         private void narisiKrogce(Graphics g) { //draw small circles (as many as user wants, max. is 256 of Hue values!
              for(int i=0; i<stKrogcev; i++) {
                   x=(r2/2)*(Math.cos(vmesniKot*i)+1);
                   y=(r2/2)*(Math.sin(vmesniKot*i)+1);
                           //can't use below two because of the "fillHSB"=="napolniHSB" method not working
                   //Color c = new Color(Integer.parseInt(red),Integer.parseInt(green[i]),Integer.parseInt(blue[i]));
                   //g.setColor(c);
                   g.drawOval((int)x, (int)y, (int)r3, (int)r3);
                   narisiLegendo((int)x,(int)y, i, g); //draw a legend (last method)
         private void napolniHSB(Graphics g) { //fillHSB method
    float h=0, raise=1.0f/stKrogcev;
    for (int i=0; i<stKrogcev; i++) {
    hsb[i]=Color.getHSBColor(h,1.0f,1.0f); // LINE 75
    red[i]=Integer.toString(hsb[i].getRed()); // this and below two for converting HSB/HSL into RGB
    green[i]=Integer.toString(hsb[i].getGreen());
    blue[i]=Integer.toString(hsb[i].getBlue());
    h+=raise;
         private void narisiLegendo(int x, int y, int i, Graphics g) { //draw a legend, i.e. 4 right columns
    //can't use drawString as there are no color arrays (yet)
                   g.drawLine((int)(x+r3/2),(int)(y+r3/2),getWidth()-ROB,(visina+i*visina)+visina/2);
                   g.drawRect(getWidth()-ROB, (visina+i*visina), sirina, visina); //Red
                   //g.drawString(red[i], getWidth()-ROB, (visina+i*visina));
                   g.drawRect(getWidth()-ROB+sirina, (visina+i*visina), sirina, visina); //Green
                   //g.drawString(green[i], getWidth()-ROB, (visina+i*visina));
                   g.drawRect(getWidth()-ROB+2*sirina, (visina+i*visina), sirina, visina); //Blue
                   //g.drawString(blue[i], getWidth()-ROB, (visina+i*visina));
                   g.drawRect(getWidth()-ROB+3*sirina, (visina+i*visina), sirina, visina); //Hue
                   //g.drawString(, getWidth()-ROB, (visina+i*visina));

  • How to build an array using incoming stream of data?

    I am programming in VBAI but use LV as my Inspection Interface. The VBAI program will go in a finite loop (1000x) and feed the numeric indicator with dbl vaule in the front panel of LV. So the dbl value is in sequence.
    In LV, how do I build an array (index 0 - 999) with this stream of data?
    Solved!
    Go to Solution.

    altenbach wrote:
    You can eliminate that useless FOR loop by using a globally initialized feedback node instead of a shift register.
    You also need a mechanism to reset the shift register contents.
    What are you doing up at this hour?  Don't you sleep?  Per your advice.  The OP will still need to code in an initial state for the array.
    Reese, (former CLAD, future CLD)
    Some people call me the Space Cowboy!
    Some call me the gangster of love.
    Some people call me MoReese!
    ...I'm right here baby, right here, right here, right here at home

  • Hiow to build digital waveform with transition values bigger U32?

    Greetings!
    Is that possible to build digital data with transitions values represented bigger than U32 values? (It seems to me that Labview 8.0 cannot accept U64. See attachment.)
    What do you recommend? I cannot change dt, so scaling does not work. This is because, the record length could be very long...and the waveform should be connected to a digital waveform graph.
    Thanks in advance!
    Attachments:
    ReplaceTransitionValues.jpg ‏21 KB

    Hello Dawid,
    Thank you for the answer.
    Yes, I'd like to build a big array, which although would not be so big... I have not so many samples (just a few thousands) but the samples could be very far from each other. That's why I need U64.
    I'm using compressed digital waveform to transport and display the samples, where the transition value functions as an offset (counted in dt) from the first sample.
    For example, to store a 1Hz signal  with sampling rate 100MHz the transitions will accumulate by 50M. If the record has 1000 samples then the last transition value will reach 50G which is much bigger than a U32 can store.
    You might ask why so high the sampling rate for a 1Hz signal... The signal is stochastic, could be faster, and I would like to keep tha fast pulses also.
    I dig into the "Append digital samples.vi" (see attachment) and I found the transition array is build by U32... I hope I did not misunderstand you, but I think it does not help. I suspect even the Digital Waveform Graph itself is not able to accept values over the U32 range, however, I should try that.
    Best Regards,
    Lamaze
    Attachments:
    AppendSamples.jpg ‏155 KB

  • How can I build an array not knowing final size at startup?

    Hi,
    I need to be able to build an array with a certain number of rows but that number is not known at runtime. Instead it can't exceed 5 in a certain time period. So my question is: every 20 seconds I need to send out the 5 row array but if lets say 10 rows of data come in in 20 seconds I am not sure how to handle the data to have it build 2 arrays and send them out one after another at the elapse of the 20 seconds as opposed to just sending an array with 10 rows and losing half the data on the receiving side. Please any help will be appreciated,
    Alex

    I understand that you have to send a least a message every 20 seconds (could be empty ?), but can you send more messages if you get more data (e.g. 3 message of 5 rows in 20 sec) ?
    If you can, then all you have to do is to trigger the sending of a message each time the array size reaches 5, or if 20s ellapsed since last sent message.
    Here is an example, using shift registers. there is a random data generation so that you can see it working (if you set the time between data long enough, then you will see the data sent after 20 sec. Well not exactly 20 sec, but i guess you can figure this out later by yourself...)
    I hope this will be of any help
    Attachments:
    dynamic_array.vi ‏36 KB

Maybe you are looking for

  • What a mess !! : ORA-01000: maximum open cursors exceeded

    I have read a lot of article about this error I m also having this problem with 8.1.6.0 or 8.1.6.1 oracle db ( and classes112 jdbc drivers ) and my application I have checked that I close every statment,preparedstatment,recordset and connection ( con

  • Gmail no longer working on ios products mail

    Good morning...I posted something the other day about being unable to get mail on my iphone..I followed directions..unlockedcaptcha and revoked access in the two step process. I got it working for about a day and now its out again on both iphone 5 an

  • Repo error:ORA-01422:exact fetch returns more than requested number of rows

    Hello, on my page I have some input fields and a report based on a query (PL/SQL function body returning SQL-Statement). The Where-Clause from this sql-statement depends on the values of the input fields. I listed the sql-Statement via htp.p (q ) and

  • What's the best flash to use for nighttime sports games?

    What's the best flash to use for nighttime sporting events? I have a rebel XT and I'm pushing it to its limits trying to stop the action. I've tried a speedlite 430 but it didn't have a hook up for an external battery pack and I was told I'd need the

  • Mac OS X Kernel Crash

    When watching a video stream on full screen (http://www.rtl.nl/components/shows/ditwashetnieuws/index_video.xml - won't stream outside of the NL), my macbook crashed twice in exactly the same way. It is as if a curtain goes down in the screen (top to