LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Transfering data from matlab to labview

Solved!
Go to solution

I am having a problem importing data I save with Matlab into Labview. From the NI website I gathered this information:

 

  1. To save a vector or a matrix Xin ASCII format with tab delimiter, enter the following in the command window or m-script file in the MATLAB® environment:
    >>SAVE filename X   -ascii -double -tabs
    This creates a file whose name is filename, and it contains the data X in ASCII format with a tab delimiter.

  2. Import the file into LabVIEW using the Read From Spreadsheet File VI located on the Programming»File I/O palette.

 

However, when I import something like a m x n matrix into labview, I get a m x (n+1) matrix, with the extra column being all zeros. This should have a simple answer...I know I can reshape matrices, etc, but it would seem as if this could be avoided. I just can't seem to figure it out and am pressed for time. Any help would be appreciated.

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

I don't know what matlab generates, but I suspect there might be an extra linefeed at the end or the lines end in /t/n, for example.

 

Can you attach a typical file so we can analyze?

 

In any case, if it is reproducible, all you need is delete the extra row or column, it's not a huge problem.

 

(You should also be careful with the lingo: You are dealing with 2D arrays, not matrices on the LabVIEW side. The reshape operation is most likely the wrong operation for what you are describing and would only work for removing some rows, not columns).

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

Thanks for the reply,

I need to import files such as "test.txt" into Labview 9.5 (see attached). If there is a command other than reshape (I could always transpose and use reshape, correct?), what would be the best? I am trying to make this program user friendly, so I prefer not to manually delete any lines. Of couse, if the problem is how I am writing the file in Matlab, then perhaps I am on the wrong message board.

 

 

0 Kudos
Message 3 of 6
(2,593 Views)

There is no LabVIEW 9.5.

 

As suspected, your lines end in \t\n.

0 Kudos
Message 4 of 6
(2,590 Views)
Solution
Accepted by topic author wilcoxds

How big are the files? Simply removing the last colum using "delete from array" is probably the easiest solution.

0 Kudos
Message 5 of 6
(2,569 Views)

They are not big. I guess that will be the easiest solution, because if I remove /n, the files are written as rows, not arrays.

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