LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read a file, calculate the momentum of two columns and calc a summation of them

I have a file which das three columns. The first of them isn't important for this problem. I have to read the second and the thid ones, and then mutiply them (to calculate the momentum), if they are at the same line. After that I need to sum all the results that I calculated.

How can I do this?






0 Kudos
Message 1 of 3
(2,723 Views)

If all the data in the file are numeric values you can use the Read From Spreedsheet File VI to get the 2-D array of data.  Then use the index array function and index out column 1 and 2.  Then multiple the arrays together, and then there is a Sum array elements VI that should finish it off.

See the attached image

Message 2 of 3
(2,702 Views)

It would depend on your file format. Lets assume is spreadsheet compatible format such as comma or tab delimited.

1. Use the Read From Spreadsheet.vi. This will give you an 2D array of numbers.

2. Use Index Array to extract the second and third colums which would be column index 1 and 2 if you don't want the first column (index 0).

3 The array data from your second and third columns will be 1D arrays which can be muliplied together using Multiply function.

4. The last think to do is to feed the mulitplied 1D array from step four into Add Array Elements function.

5. Create an indicator from the output of Add Array Elements and that should be you.

Have a go and see how you get on.

David

Message 3 of 3
(2,700 Views)