LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Process 2D Array String

Solved!
Go to solution

Hello  everyone

 

I want to make a program about the directions of eye movements. The input is from Excel Signal Data.

I input my Excel data using Read From Spreadsheet File and use the String One.

I have two signals: Ch1 and Ch2.

To make the program I have to read each column, so I have to separate the column. I tried to use index array but it didn't work, and I tried to use Spreadsheet string to array and it didn't work either because of the type of data is 2d array. What should I do to solve this?

 

Here I attached my vi and my excel data

Download All
0 Kudos
Message 1 of 19
(3,245 Views)
Solution
Accepted by topic author jennichrni

Your column delimiter is a semicolon, not a double-space.

To get the first column, you need to wire the column index to the lower of the two index terminals.

 

altenbach_0-1587792300976.png 

altenbach_1-1587792342110.png

 

Now you also need to remove the column header. See how far you get.

 

(Your while loop spins millions of times per second, reading the same file over and over. Seems pointless. Right?)

Message 2 of 19
(3,227 Views)

Thank you for the replied, It did work. How do I kwon my while loop is spins millions of times per second?

and why I have to remove the header?

 

Regards

Jenni

0 Kudos
Message 3 of 19
(3,161 Views)

Your while loop is spinning as fast as the computer allows, repeating the same operations over and over. Since the results never changes, that's just pumping a lot of hot air for nothing. It is sufficient to read the file once. You don't need the loop at all.

 

(If you want a toplevel polling loop, you would place a short wait in it (e.g. 50ms).Look in the timing palette. Alternatively, use an event structure that only repeats the code whenever the file name is changed)

 

You don't have to remove the headers, but if you want to process the numbers (e.g. for a graph or calculation), the headers need to be handled separately.

Message 4 of 19
(3,153 Views)

Thank you so much for your respond. 

I understand,  so I have to put delay to my labview program. 

Can I ask you another question? 

I want to process the data in array,  is it better to change it to Number data type or I just let in in String data type?  Because I want to make program with threshold detector and peak detector to process the signal.

 

If it's better to be changed, how can I change 1D array string to number? I've tried some example from forum but all of these got bad terminal things. 

 

The program that I want to make maybe will be similar with this. 

 

Regards

Jenni

0 Kudos
Message 5 of 19
(3,137 Views)

You cannot do math with strings, so you need numeric datatype for all that (and the header would turn onto a zero, which is misleading, so remove the headers)..

 

To convert a string to number, use "fract/exp string to number" (works with scalars and arrays with any number of dimensions equally well).

 

altenbach_0-1587915960953.png

 

 

Whatever you have attached is not a snippet, just a flat image, so we can't really do anything with it. Can you attach the actual VI? Make sure your string contains typical default data. Also maybe include a picture explaining graphically what you want to count and what result you are expecting as result.

 

 

Message 6 of 19
(3,124 Views)

Thank You for your response.

I have tried using fract/exp string to number but the numbers after the commas didn't show up. The data become integer. I'll do the threshold program like this:

If Ch1 >-0,5 & Ch1 <0.5

true: Ch1 = 0

false: Ch1=Ch1

But when I tried using case structure, it's an error.

 

Here I attach the Vi and the data

Thank You

Regards

Jenni

Download All
0 Kudos
Message 7 of 19
(3,102 Views)

Works fine here. What is your system decimal point ("." or ","?). Why did you change these boolean constants to FALSE?

 

To zero all points that are out of range, use e.g. this:

 

altenbach_0-1587965825576.png

 

Message 8 of 19
(3,092 Views)

Thank you for your response,

my system decimal point is (.)

 

-What you you change these boolean constants to FALSE?-

I'm sorry but what do you mean by this?

altenbach_0-1587965825576.png

Sorry, but may I know the name of the icon you use? 😅

 

Thank You

Regards,

Jenni

0 Kudos
Message 9 of 19
(3,074 Views)

 

The boolean array will be TRUE for all array elements that are in the range defined by the limits, and zero otherwise. Converting that to numbers (TRUE:1, FALSE:0). Multiplying that with your data will zero all elements that are out of range and leave the others untouched.

 


@jennichrni wrote:

-What you you change these boolean constants to FALSE?-

I'm sorry but what do you mean by this?


You have TRUE wired to the fract/exp string to number function. Change that to FALSE and see if it helps

Message 10 of 19
(3,069 Views)