07-06-2009 07:00 AM
Comparison:
test code in Matlab:
AA = [1 2 3 4 5];
save AA-matlab.mat AA;
and test code in LabView MathScript Node
AA = [1 2 3 4 5];
save 'AA-LV-matlab.mat' AA;
Both scripts make a file, but different files.
File made using LabView is NOT readable in Matlab! Save in LabView is not same as save in Matlab. Why this incompatibility? How to make compatible files?
Check Spelling in this editor gives suggestion LabView > Labile. True?
07-06-2009 09:39 AM - edited 07-06-2009 09:40 AM
As I noted to another user MathScript is not the same as Matlab. MathScript is NI's version of a Matlab-like language. As documented in the Help for that functions, it doesn't say anything about saving to Matlab .mat files.
Your options:
Check Spelling in this editor gives suggestion LabView > Labile. True?
This is a known problem.
07-08-2009 06:08 AM
Thank you for help.
Matlab Script Node is not so easy to use. This is why I first tried to use MathScipt. NI KnowledgeBase has a number of stories how to try to get LabView-Matlab communication work. After reading those and some MathWorks documentation I managed to do that.
Now I have in Matlab Script Node simple working test code:
%Matlab MUST be started BEFORE running LabView vi containing MATLAB Script Node.
%Matlab MUST be started with options -automation -nojvm.
% Change matlab working directory. Saved files go in that directory.
%
cd 'C:\Documents and Settings\veuitto\My Documents\LabVIEW Data'
AA = [1 2 3 4 5];
save 'AA-LV-matlab.mat' AA;
Warning:
I do not know how it works or why it works if works. It is possible to go (accidentally) to a state where LabView gives no warning or error message and it saves no file. I guess that it happens if LabView is running but Matlab is turned off and started again.
If opening LabView vi (containing Matlab Script Node) takes very long time, most probably link between LabView and Matlab do not work.
I really hope that some day I see proper documentation about Matlab Script Node.
VesaU
07-08-2009 08:57 AM
07-09-2009 01:11 AM
Hello Veteran,
Just saving a vector to a .mat file? Yes this is my target. Why? Let's assume that we have raw data files from two NI6259. We may get 2 million samples/second. A short test gives me 100MB or more data. Saving data to text file for exporting to Matlab-analysis is not very good idea. Why Matlab? Matlab is widely used for mathematical analysis. We use Matlab and our partners use it.
Today we use Matlab DAQ Toolbox with NI DAQ cards. Now I am checking is it possible to use LabView for DAQ and still use Matlab for analysis and visualization. We have lot of own tools in Matlab. It is not easy to throw Matlab away.
Why to change from Matlab DAQ Toolbox to LabView?
1. Matlab DAQ Toolbox has some limitations compared to LabView. Limitations are not very critical for us.
2. Change from NIDAQ to NIDAQmx was not a success story. Now we have four times bigger datafiles in Matlab because NIDAQmx uses longer numerical expression than earlier. Old NIDAQ we use with PCI and PCMCIA cards but new USB hardware forces us to use NIDAQmx.
I have asked help from MathWorks and National Instruments to solve the problem. Both companies say that the fault is on the other side. I think that both companies should face the truth. It should not be end user's problem. It may happen that end user find a third software + hardware which is working. I think that it is easier to change DAQ than analysis package.
One possible solution is a tool for Matlab to read smootly LabView TDM+TDX or TDMS files. Those tools which I have found are not real tools for that purpose. Labile converters.
Kind regards
Vesa
07-09-2009 03:54 AM
VesaU,
actually what I think he tried to say is that you can still use MatLab, but save your data from LabVIEW in txt files (which can be read by MatLab later). Then you won't need to use the MathScript, just regular LabVIEW coding...
07-09-2009 05:34 AM
07-09-2009 05:58 AM
I tried to say that TXT file method is not a method for today or tomorrow. I have used that 1990's. It is almost same as pen and paper. Something better I want for tomorrow.
TXT file is OK, if it is used once in a year or month. For daily work it is not a solution.
Solutions for tomorrow may be:
1. Matlab reading directly LabView data files.
2. Converting LabView data files (TDM/TDX files) to MAT files. Mat file with all relevant data from TDM/TDX file into a Matlab Struct.
VesaU
07-09-2009 09:02 AM
Danigno wrote:VesaU,
actually what I think he tried to say is that you can still use MatLab, but save your data from LabVIEW in txt files (which can be read by MatLab later). Then you won't need to use the MathScript, just regular LabVIEW coding...
Yup, that was exactly what I was saying. Thanks for the clarification.
VesaU wrote:
Just saving a vector to a .mat file? Yes this is my target. Why? Let's assume that we have raw data files from two NI6259. We may get 2 million samples/second. A short test gives me 100MB or more data. Saving data to text file for exporting to Matlab-analysis is not very good idea. Why Matlab? Matlab is widely used for mathematical analysis. We use Matlab and our partners use it.
I tried to say that TXT file method is not a method for today or tomorrow. I have used that 1990's. It is almost same as pen and paper. Something better I want for tomorrow.
TXT file is OK, if it is used once in a year or month. For daily work it is not a solution.
Solutions for tomorrow may be:
1. Matlab reading directly LabView data files.
2. Converting LabView data files (TDM/TDX files) to MAT files. Mat file with all relevant data from TDM/TDX file into a Matlab Struct.
You're starting to be a little defensive here for no reason. You had provided NO information as to what you were saving, or how much data you were saving, and to belittle a suggestion that was based on virtually no facts is like biting the hand that tries to feed you. Not a very good way to make friends.
As pointed out by Danigno, I wasn't telling you NOT to use Matlab, but rather to change how you were saving the file since the data was apparently (though I'm wasn't sure since you provided no information) being saved in LabVIEW. Obviously, saving data as a text file for that amount of data is not warranted. If you were still going to collect the data in LabVIEW then a binary file would be something that can be used by both LabVIEW and Matlab, though you have to watch the endianness since LabVIEW defaults to big endian, and I believe Matlab defaults to little endian.
2. Change from NIDAQ to NIDAQmx was not a success story. Now we have four times bigger datafiles in Matlab because NIDAQmx uses longer numerical expression than earlier. Old NIDAQ we use with PCI and PCMCIA cards but new USB hardware forces us to use NIDAQmx.
I don't understand what you mean by this. What functions were you using, and how were you saving the data?
I have asked help from MathWorks and National Instruments to solve the problem. Both companies say that the fault is on the other side. I think that both companies should face the truth. It should not be end user's problem. It may happen that end user find a third software + hardware which is working. I think that it is easier to change DAQ than analysis package.
I'm not here to defend either NI or Mathworks, but I think that's debatable.
07-09-2009 09:16 AM
smercurio_fc, it's certainly possible to waste a lot of time dealing with just one complex or proprietary storage format (mat, tdms, hdf, hdf5) let alone trying to get third-party software working with it.
That said, it would be nice if NI would come up with a better documented or more workable way to get tdms files into other formats.