LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Building an array of difference values

Solved!
Go to solution

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,

0 Kudos
Message 1 of 7
(3,032 Views)

N-n-1.png

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 7
(3,024 Views)

Thanks for your response however when I tried to implement your idea there are several problems (see attached)

0 Kudos
Message 3 of 7
(3,017 Views)

You are working with a 2-D array in your VI, yet you describe a 1-D array in your question.  So what do you want to do with a 2-D array?

 

Rather than working in a For Loop, you could take a subset of the original array starting at the second element and subtract it from itself.

0 Kudos
Message 4 of 7
(3,010 Views)

Basically you can put my code inside a for-loop, then it'll extract each row and do the calculations on that. Is that what you want to do? Else you can Transpose the array if it's the columns you want to calculate ...

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 7
(3,003 Views)

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,

0 Kudos
Message 6 of 7
(2,981 Views)
Solution
Accepted by bunnykins

Since you have 1 column by 800 rows, then use Index Array first to get only the first column.  This will give you a 1-D array of 800 elements.  Then the idea of using that array, along with array subset for the 2nd through remaining rows, subtract one from the other, will work.

 

I can't comment on simulation loops because I don't have that and have never used it.

 

Message 7 of 7
(2,963 Views)