501
edits
No edit summary |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
The code below shows an example of how to load a matrix from a file in Octave's binary file format. | The code below shows an example of how to load a matrix from a file in Octave's binary file format. | ||
An example of how to load data from a file in Octave's ascii format can be found in this | An example of how to load data from a file in Octave's ascii format can be found in this [[fortran|page]]. | ||
{{Code|octave_binary_io_example.cc: C++ function to load a matrix from a BINARY file in Octave native format|<syntaxhighlight lang="C" style="font-size:13px"> | {{Code|octave_binary_io_example.cc: C++ function to load a matrix from a BINARY file in Octave native format|<syntaxhighlight lang="C" style="font-size:13px"> | ||
Line 19: | Line 19: | ||
std::fstream file; | std::fstream file; | ||
std::ios::openmode m = std::ios::in; | std::ios::openmode m = std::ios::in; | ||
load_save_format format = LS_BINARY; | load_save_format format = LS_BINARY; | ||
oct_mach_info::float_format flt_fmt = oct_mach_info::flt_fmt_unknown; | oct_mach_info::float_format flt_fmt = oct_mach_info::flt_fmt_unknown; | ||
Line 27: | Line 25: | ||
int main (void) | int main (void) | ||
{ | { | ||
string_vector argv (1); | string_vector argv (1); | ||
Line 72: | Line 66: | ||
$ mkoctfile --link-stand-alone octave_binary_io_example.cc | $ mkoctfile --link-stand-alone octave_binary_io_example.cc | ||
$ ./a. | $ ./a.out | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
[[Category:Examples]] |
edits