LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write array to text file

Hello All,

I need to know that how can I write a 1D array of double [64-bit real (~15 digit precision)] to a .txt file for post-processing in other tools like Matlab. The .txt file should consist of 1 column only, an example of the required .txt file format is attached.  

P.S. The array is too large Smiley Sad

 

Regards

 

0 Kudos
Message 1 of 16
(9,441 Views)

You can use the 'write to spreadsheet file' VI which is in the File I/O pallette.

 

http://zone.ni.com/reference/en-XX/help/371361J-01/glang/write_to_spreadsheet_file/

0 Kudos
Message 2 of 16
(9,434 Views)

Hi

Use write to spreadsheet vi.

0 Kudos
Message 3 of 16
(9,433 Views)

Thanks for reply, I already used write to text as well as write to spreadsheet.vi but it gives me a matrix where I need a vector having only one colum and all the data lies sequecially in that column as shown in the test.txt file. Any help in this regard will be appreciated...

Regards

0 Kudos
Message 4 of 16
(9,418 Views)

Can you post your vi and its output.  Not sure what you mean when you say it gives you a matrix.

 

Ken

0 Kudos
Message 5 of 16
(9,410 Views)

Change the 'Transpose' input on Write to Spreadsheet to true.

Capture.PNG

 

 

 

0 Kudos
Message 6 of 16
(9,409 Views)

Hello,

The output of the the array is 1D array of double [64-bit real (~15 digit precision)] and I want to save it as single column .txt file (as shown in the attachement in the first message of this thread) in order to read that .txt file in MATLAB for post-processing.

Using write to spreadsheet or text.vi file give me the .txt file but the data is distributed in more than 1 column where I need all the data to be stored in one column (as vector) so that MATLAB can read the .txt file.

Regards

0 Kudos
Message 7 of 16
(9,384 Views)

Hi attique,

 

it has been told to you several times, but still you don't use "Write to spreadsheet file"...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 16
(9,372 Views)

You have to post your complete code. The image you updated doesn't show you are writing to a spreadsheet.vi where it will take it without any issue. You are trying to connect the double value to a text input of the file before that you need to convert that to spreadheet string and then write to the text file vi.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 9 of 16
(9,368 Views)

What is wrong with Phil_'s code?  That is exactly what you need.

 

Your other option would be to use the Array to Spreadsheet String and then write to the text file (which is really what is done inside of the Write to Spreadsheet String).


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 10 of 16
(9,362 Views)