diff --git a/matlab/@dynSeries/pop.m b/matlab/@dynSeries/pop.m
index c56c4f0d024be91525502a0f514585e49a33b850..b6c178ed0f1b2e9cdcd0c5f239b8ccbcf11035dc 100644
--- a/matlab/@dynSeries/pop.m
+++ b/matlab/@dynSeries/pop.m
@@ -45,6 +45,10 @@ function [ts,id] = pop(ts,a)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
id = strmatch(a,ts.name,'exact');
+if isempty(id)
+ id = 0;
+ return
+end
ts.vobs = ts.vobs-1;
ts.data(:,id) = [];
ts.name(id) = [];
@@ -75,3 +79,28 @@ ts.tex(id) = [];
%$ end
%$ T = all(t);
%@eof:1
+
+%@test:1
+%$ % Define a datasets.
+%$ A = rand(10,3);
+%$
+%$ % Define names
+%$ A_name = {'A1';'A2';'A3'};
+%$
+%$ t = zeros(2,1);
+%$
+%$ % Instantiate a time series object.
+%$ try
+%$ ts1 = dynSeries(A,[],A_name,[]);
+%$ [ts2,id] = pop(ts1,'A4');
+%$ t(1) = 1;
+%$ catch
+%$ t = 0;
+%$ end
+%$
+%$ if length(t)>1
+%$ t(2) = dyn_assert(id,0);
+%$ t(2) = dyn_assert(ts1==ts2,1);
+%$ end
+%$ T = all(t);
+%@eof:1