Commit fdc8b48b authored by Pierre Cazenave's avatar Pierre Cazenave
Browse files

Modify the call to unique to not use the 'stable' flag because it's not...

Modify the call to unique to not use the 'stable' flag because it's not present in versions of MATLAB prior to 2012a. This approach should still give the unique values of the array in the original order in which they were presented (using the last duplicate in each set of duplicates)
parent af456559
......@@ -26,11 +26,11 @@ function [Mobj] = add_obc_nodes_list(Mobj,Nlist,ObcName,ObcType,plotFig)
% Pierre Cazenave (Plymouth Marine Laboratory)
% Karen Amoudry (National Oceanography Centre, Liverpool)
%
%
% Revision history:
% 2012-11-26 Add ability to turn off the figures.
% 2013-01-02 KJA bug fix: amended usage of 'unique' in line 50 to
% prevent it from sorting the values it returns.
% 2013-01-02 KJA bug fix: amended usage of 'unique' in line 53 to
% prevent it from sorting the values it returns. Amended by Pierre to
% support pre-2012 versions of MATLAB whilst giving the same result.
%
%==========================================================================
subname = 'add_obc_nodes';
......@@ -48,7 +48,10 @@ end
%--------------------------------------------------------------------------
% Get a unique list and make sure they are in the range of node numbers
%--------------------------------------------------------------------------
Nlist = unique(Nlist,'stable');
% Make this works in versions of MATLAB older than 2012a (newer versions
% can just use unique(A, 'stable'), but checking versions is a pain).
[~, Nidx] = unique(Nlist);
Nlist = Nlist(sort(Nidx));
if(max(Nlist) > Mobj.nVerts);
fprintf('your open boundary node number exceed the total number of nodes in the domain\n');
......
......@@ -28,7 +28,8 @@ function [Mobj] = add_river_nodes_list(Mobj,Nlist,RiverName)
%
% Revision history
% 2013-01-02 KJA bug fix: amended usage of 'unique' to prevent it from
% sorting the values it returns.
% sorting the values it returns. Amended by Pierre to support pre-2012
% versions of MATLAB whilst giving the same result.
%
%==========================================================================
subname = 'add_river_nodes_list';
......@@ -41,7 +42,10 @@ end
%--------------------------------------------------------------------------
% Get a unique list and make sure they are in the range of node numbers
%--------------------------------------------------------------------------
Nlist = unique(Nlist,'stable');
% Make this works in versions of MATLAB older than 2012a (newer versions
% can just use unique(A, 'stable'), but checking versions is a pain).
[~, Nidx] = unique(Nlist);
Nlist = Nlist(sort(Nidx));
if max(Nlist) > Mobj.nVerts
fprintf('your river node number(s) exceed the total number of nodes in the domain\n');
......
......@@ -23,10 +23,12 @@ function [spongeRadius] = calc_sponge_radius(Mobj,Nlist)
%
% Author(s)
% Karen Amoudry (National Oceanography Centre, Liverpool)
% Pierre Cazenave (Plymouth Marine Laboratory)
%
% Revision history:
% 2013-01-02 KJA bug fix: amended usage of 'unique' to prevent it from
% sorting the values it returns.
% sorting the values it returns. Amended by Pierre to support pre-2012
% versions of MATLAB whilst giving the same result.
%
%==========================================================================
subname = 'calc_sponge_radius';
......@@ -39,7 +41,10 @@ end
%--------------------------------------------------------------------------
% Get a unique list and make sure they are in the range of node numbers
%--------------------------------------------------------------------------
Nlist = unique(Nlist,'stable');
% Make this works in versions of MATLAB older than 2012a (newer versions
% can just use unique(A, 'stable'), but checking versions is a pain).
[~, Nidx] = unique(Nlist);
Nlist = Nlist(sort(Nidx));
spongeRadius = 100000+zeros(size(Nlist));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment