altmany / export_fig

A MATLAB toolbox for exporting publication quality figures
BSD 3-Clause "New" or "Revised" License
1.28k stars 368 forks source link

Use of `size` function in `getPrintImage` in pre-R2019b #308

Closed TCWORLD closed 4 years ago

TCWORLD commented 4 years ago

In export_fig v3.06 and newer, when using MATLAB pre-R2019b, the function getPrintImage in print2array.m will fail.

This is because MATLAB changed the behaviour of the size function. The ability to pass in multiple dimensions was introduced in R2019b.

Simply changing line 319 of print2array.m from:

    imgSize = size(imgData,[1,2]);

To this:

    imgSize = size(imgData);
    imgSize = imgSize([1,2]);

Fixes the problem in older versions of MATLAB.

While I understand that supporting old versions of MATLAB can be tricky, it seems like its a worthwhile change as it should have no impact on performance so is a win win really.

altmany commented 4 years ago

Fixed

TCWORLD commented 4 years ago

Thanks for the quick fix.