Bizarre errors with contour command (matlab 2014a vs later versions)

1 view (last 30 days)
I have some legacy codes that worked fine with 2014a and earlier versions. As we all know, 2014b and later versions changed things a lot, leading to lots of broken codes.
I am getting some weird errors running this line of code in 2014a and 2017a:
% 'grid' and 'diag' are structural variables. The line below is finding the contours of some 2d field (diag.sla)
% for a particular contour value (15)
cont_km = contour(grid.xkm, grid.ykm, diag.sla, [15.0 15.0]) ;
When I run this command in 2014a and 2017a, I get different results as cont_km has different sizes. That is, 2017a is identifying a different number of contours for the same field at the same contour level on the same grid!
I have checked the input variables grid.xkm, grid.ykm, diag.sla are identical when I run the command in both the versions.
Did mathworks change how the contour command works after 2014a?
Any help is appreciated.
  3 Comments
oceanmod
oceanmod on 27 May 2020
But that wouldn't make any sense. The number of contours should not change depending on the version number (obviously).
Rik
Rik on 27 May 2020
Contour plots are not an exact science. If you had found a difference between the values that sqrt returns, then you would have found a bug in one or both versions.
Even a function like imclose can change behavior in edge cases (in the case of this function quite literally).
If you want thing to be stable between releases you will have to do a lot yourself, which is going to cost a lot time (design time, execution time, or both).

Sign in to comment.

Answers (0)

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Products


Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!