help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to save matrix from an oct file


From: Carlo de Falco
Subject: how to save matrix from an oct file
Date: Tue, 11 May 2010 12:54:53 +0200

Hi,
for debugging an oct file I am working on, I would like to save a SparseMatrix to a file so that I can later load it in octave and inspect it.

I naively tried the following:

1) for ascii format

SparseMatrix mat;

....

std::ofstream os ("mat.txt");
octave_value (mat).save_ascii (os);
os.close();

which seems to work but saves the matrix entries in IJV format and I have to later convert them with spconvert.

2) for binary format

std::ofstream os ("mat.mat");
bool boolvar(false);
octave_value (mat).save_binary (os, boolvar);
os.close();

which doesn't seem to work correctly as

>> load mat.mat
error: load: mat.mat: inconsistent number of columns near line 2
error: load: unable to extract matrix size from file `mat.mat'

What is the correct way to do this?
Thanks in advance,
c.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]