LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write an array and a scalar to file?

Solved!
Go to solution

I would like to write my data to a file but am having trouble approaching the problem. In the file I would like to write both the x and y values of my data points in two columns, however, the y data is in an array and the x data is made up of 3 pieces of information: an initial x, an x incremented value, and the number of points in my data sample. How could I go about this?

0 Kudos
Message 1 of 6
(2,973 Views)

Would it be best to create an array of the x values by

 

[x, x+delta_x, x+ 2delta_x ..... , x+(n-1)delta_x]

 

where n= to the number of dimensions in the array

 

and then build a two dimensional array of both the x and y values?

0 Kudos
Message 2 of 6
(2,968 Views)

Hello

 

you could do the way you suggested.

 

Use a For loop, connect your 'number of samples' to N count, build an array [of x+(n-1)delta_x]. Use 'i' iteration number as your (n-1)

 

Build a 2D array, of x array and y array.

 

Then, if you are writing to a spreasheet file, wire the 2D array directly. If you are writing to a text file, use the Array to Spreasheet string and write to the text file

 

Edit: Note that n is not the number of dimensions, its number of elements in a 1D array

Regards
Freelance_LV
TestAutomation Consultant
Message 3 of 6
(2,953 Views)

@Freelance_LV wrote:

Hello

 

you could do the way you suggested.

 

Use a For loop, connect your 'number of samples' to N count, build an array [of x+(n-1)delta_x]. Use 'i' iteration number as your (n-1)

 

 


Another option for this is to use the ramp pattern.vi which will do it for you and eliminate the need for you to code up the incrementing inside a for loop

Message 4 of 6
(2,948 Views)
Solution
Accepted by MIMaracuya

The number of points is redundant, because it will be the same as the "other" array.

 

Here's what I usually do:

 

 

Message 5 of 6
(2,947 Views)

Thanks everyone, it's looking great now!

0 Kudos
Message 6 of 6
(2,918 Views)