02-21-2012 05:39 PM
I am having a problem importing data I save with Matlab into Labview. From the NI website I gathered this information:
>>SAVE filename X -ascii -double -tabsThis creates a file whose name is filename, and it contains the data X in ASCII format with a tab delimiter.
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.
Solved! Go to Solution.
02-21-2012 05:50 PM - edited 02-21-2012 05:58 PM
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).
02-21-2012 07:01 PM
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.
02-21-2012 07:03 PM - edited 02-21-2012 07:05 PM
02-22-2012 01:27 AM - edited 02-22-2012 09:03 AM
How big are the files? Simply removing the last colum using "delete from array" is probably the easiest solution.
02-22-2012 08:57 AM
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.