octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #48408] save -append should overwrite a variab


From: Rik
Subject: [Octave-bug-tracker] [bug #48408] save -append should overwrite a variable with the same name
Date: Tue, 5 Jul 2016 22:00:10 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Update of bug #48408 (project octave):

                Priority:                 3 - Low => 5 - Normal             
                 Release:                     dev => 4.0.3                  

    _______________________________________________________

Follow-up Comment #6:

The easy way to update variables is not to use Matlab ;)

-append certainly works in Octave by itself, and in Matlab by itself.  If you
want to swap data files between the two then just make sure you write out all
the variables you need.

For example,


varnames = {'x', 'b'};
save ('-v7', 'tst.mat', varnames{:})


jwe's suggestion works fine.  But load/save are both implemented in C++ rather
than as m-files.  This means it is not quite as simple to code up, even though
the concept is fine.

You could always write your own wrapper around save.  Something vaguely like
this:


function save_append (fname, varargin)
  s = load (fname); 
  for i = 1:numel (varargin)
     varname = varargin{i};
     if (exist (varname, "var"))
       s.(varname) = __varval__ (varname);
     endif
  endfor
  save ("-v7", fname, "-struct", s);
endfunction





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?48408>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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