public class MatFileWriter extends Object
//1. First create example arrays
double[] src = new double[] { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
MLDouble mlDouble = new MLDouble( "double_arr", src, 3 );
MLChar mlChar = new MLChar( "char_arr", "I am dummy" );
//2. write arrays to file
ArrayList<MLArray> list = new ArrayList<MLArray>();
list.add( mlDouble );
list.add( mlChar );
new MatFileWriter( "mat_file.mat", list );
this is "equal" to Matlab commands:
<< double_arr = [ 1 2; 3 4; 5 6];
<< char_arr = 'I am dummy';
<<
<< save('mat_file.mat', 'double_arr', 'char_arr');
| Constructor and Description |
|---|
MatFileWriter()
Creates the new
instance |
MatFileWriter(File file,
Collection<MLArray> data)
Writes MLArrays into
File. |
MatFileWriter(String fileName,
Collection<MLArray> data)
Writes MLArrays into file given by
fileName. |
MatFileWriter(WritableByteChannel channel,
Collection<MLArray> data)
Writes MLArrays into
OuputSteram. |
| Modifier and Type | Method and Description |
|---|---|
void |
write(File file,
Collection<MLArray> data)
Writes
MLArrays into File |
void |
write(String filepath,
Collection<MLArray> data)
Writes
MLArrays into file created from
filepath. |
public MatFileWriter()
MatFileWriter instancepublic MatFileWriter(String fileName, Collection<MLArray> data) throws IOException
fileName.fileName - - name of ouput filedata - - Collection of MLArray elementsIOException - on underlying IOExceptionpublic MatFileWriter(File file, Collection<MLArray> data) throws IOException
File.file - - an output Filedata - - Collection of MLArray elementsIOException - on underlying IOExceptionpublic MatFileWriter(WritableByteChannel channel, Collection<MLArray> data) throws IOException
OuputSteram.
Writes MAT-file header and compressed data (miCOMPRESSED).channel - channeldata - - Collection of MLArray elementsIOException - on underlying IOExceptionspublic void write(String filepath, Collection<MLArray> data) throws IOException
MLArrays into file created from
filepath.filepath - the absolute file path of a MAT-file to which data is writtendata - the collection of MLArray objectsIOException - if error occurred during MAT-file writingpublic void write(File file, Collection<MLArray> data) throws IOException
MLArrays into Filefile - the MAT-file to which data is writtendata - the collection of MLArray objectsIOException - if error occurred during MAT-file writingCopyright © 2016. All rights reserved.