Skip to content
This repository was archived by the owner on Apr 5, 2019. It is now read-only.

Commit 9f55e4d

Browse files
committed
Fix bug with remidx
remidx could exceed the number of legend entries. For example: ```matlab figure ezplot sin legend sin legtools.remove(legend,2) % 2 exceeds the number of legend entries, which is 1 ``` This commit fixes this bug by throwing an error if the largest value in remidx is greater than the number of legend entries.
1 parent a701159 commit 9f55e4d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

legtools.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ function remove(lh, remidx)
133133
'number of legend entries.'] ...
134134
)
135135

136+
assert( ...
137+
max(remidx) <= numel(lh.String), ...
138+
'legtools:remove:BadSubscript', ...
139+
'Index in remidx exceeds number of legend entries.' ...
140+
)
141+
136142
if numel(unique(remidx)) == numel(lh.String)
137143
delete(lh);
138144
warning('legtools:remove:LegendDeleted', ...

0 commit comments

Comments
 (0)