bugGNU Octave - Bugs: bug #54416, save function doesn't use Matlab...

 
 

bug #54416: save function doesn't use Matlab file format by default

Submitter:  Arnaud Delorme <arnodelorme>
Submitted:  Wed 01 Aug 2018 05:33:48 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.4.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 01 Aug 2018 03:20:47 PM UTC, comment #4: 

The existing comments are correct.  Octave is not Matlab.  Often, it can run existing Matlab without modification, but occasionally small changes may be necessary for code to run simultaneously in both interpreters.  In this case there are multiple workarounds:

1) Run in maximum-compatibility mode (--traditional on command line)

2) Set up your default save format to be matlab binary which matches the default that Matlab uses.

3) Change code to include the format argument to save.  Matlab and Octave both accept this option.  According to The Mathworks, the format can be specified with this syntaxt


 save(filename,variables,fmt)


where "fmt" would be '-mat'.

Marking as "Won't Fix" and closing report.

Rik <rik5>
Group administrator
Wed 01 Aug 2018 02:11:40 PM UTC, comment #3: 

Octave already has a very easy workaround for this, simply add


save_default_options ('-mat')


to your ~/.octaverc or global octaverc to choose to use this option by default on your system.

In fact, 'octave --traditional' already sets save_default_options to '-mat-binary', so that's another way to opt in to this setting by default.

I would say that this is working as designed.

Mike Miller <mtmiller>
Group Member
Wed 01 Aug 2018 11:45:40 AM UTC, comment #2: 

I'm changing the title for this report to be "save function doesn't use Matlab file format by default".  Whether it should is debatable, but I think that's the real issue here.

John W. Eaton <jwe>
Group administrator
Wed 01 Aug 2018 06:32:42 AM UTC, comment #1: 

That's because the default formats under Matlab und Octave differ: observe that you did not specify the format for saving, therefore Octave uses its default format, while you did specify a non-standard format for loading, which obviously do not fit. I would argue that your code is no valid use-case (not even on Matlab), as you typically would want to specify the format on saving (assuming you care for some specific non-standard format), but would be happy to let load find out the correct format itself. And indeed that works, specifying "-mat" (without quotes) for save but omitting it from load.

Michael Leitner <mleitner>
Wed 01 Aug 2018 05:33:48 AM UTC, original submission:  

This code works in Matlab (since version Matlab 5.3 in 2000 and tested below in Matlab 2018a).
It generates an error under Octave though

test = 'abcd';
save tmp.mat test
load -mat tmp.mat

Basically under Octave, one has to use

save('-mat', 'tmp.mat','test')

Arnaud Delorme <arnodelorme>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by mleitner (Posted a comment)
  • -email is unavailable- added by arnodelorme (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-01 rik5 StatusNone Wont Fix
        Open/ClosedOpen Closed
        Operating SystemMac OS Any
    2018-08-01 jwe Summarysave function matlab compabitibility save function doesn't use Matlab file format by default

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code