LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from spread sheet into array

Solved!
Go to solution

Hello everyone,

I am beginner in labview and at learning stage, i am using spreadsheet into array function as you can see in below picture 1, that i have attached. Actually i have 2 problems in this VI.

1- I am not getting first line of measured data into first row of array, for reference i have uploaded picture 2. And in array there is automatically generated {0 0 0 0}  at last row in array , your can see in pictures 2.

2- In picture 1 i have mentioned the location of problem 2, i just want to put number into array but i do not know how can i do. The technique that i have used in this VI is working but not perfectly, i mean to say when i press run button its creates thousand of  zeros in start of 1D  array before getting my actual data. How can i fix this issue. please guide me i will be grateful to you.         

Download All
0 Kudos
Message 1 of 3
(1,758 Views)
Solution
Accepted by topic author Aitzaz

Hi Aitzaz,

 

why do you think you need to convert that string into a 4D array, when you just have a 2D array of values?

Change that array constant to just 2 dimension!!!

 

(Do you really need a Matlab script for that basic math? Use LabVIEW functions instead!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(1,749 Views)

1. DO NOT USE THE BYTES AT PORT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  You are just causing weird race conditions.  Your data obviously ends each line with a Line Feed, so use that by just telling the VISA Read to read more bytes than you ever expect in a row of your data.  And since your loop rate is now determined by the rate as which a line of data comes in, you can get rid of the wait in your loop.

 

2. You can process a single line at a time.  So do (1), get rid of the Concatenate String, and change your Spreadsheet String To Array to output a 1D array (why you have a 4D array is beyond me).  You can use Feedback Nodes or Shift Registers with Build Array to create your XY graphs.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(1,740 Views)