I would like to know how should I save matrix which can have a different size. I would like to save it in a binary file. How to do it in LabVIEW 6i? -- Z pozdrowieniami Szymon Klause "NightSky" Bydgoszcz e-mail: email@example.com FidoNet: 2:481/75
After having opened the file, use the "Write File" function to write the 2D array that you wire on "data" input. Also wire the "header" input to "True". To read data back from file, use "Read File" function wiring a 2D array (may be empty, just the datatype is needed) to the "byte stream type" input. File data comes from the "data" output.
The header input of "Write File" function works like this: False: variable length data (arrays and strings) are written as individual elements, that means that writing a MxN array writes M*N elements on file, without dimension or length information. Only the content of strings is written. True: the data is preceded by a header that tells the number of dimension(s) in the array and the size of each dimension. That all ows to recover on read the binary array along with its size. Strings are preceded with the length on the string so when you call the "Read File" function with a string wired to "byte stream type", a string of the length stored in the header is read.
>After having opened the file, use the "Write File" function to write >the 2D array that you wire on "data" input. Also wire the "header" [...] >File" function with a string wired to "byte stream type", a string of >the length stored in the header is read.
Thank You! It was that what I need. -- Z pozdrowieniami Szymon Klause "NightSky" Bydgoszcz e-mail: firstname.lastname@example.org FidoNet: 2:481/75
Assuming that your matrix is always 2D array of number and just a different number of rows and columns, one way is to flatten your 2D array to a string and write the string with the Write Characters to File function. To read the data, use Read Characters from File and on the string output, use an Unflatten from String function and wire a 2D array constant to the data type input.
Another way is to first write the number of rows and columns to a file and then write the data using Write to SGL File.vi. Then when you do a read, first read the number of rows and columns and then use those parameters for Read from SGL File.vi. If you are reading a writing DBL's, then make copies of the binary SGL VIs and change the data types.