diff --git a/matlab/reports/@report/addGraph.m b/matlab/reports/@report/addGraph.m
index a9b247b32..f5f48a7aa 100644
--- a/matlab/reports/@report/addGraph.m
+++ b/matlab/reports/@report/addGraph.m
@@ -29,8 +29,6 @@ function o = addGraph(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see .
-lastPage = o.pages.numPages();
-lastSection = o.pages(lastPage).numSections();
-o.pages(lastPage).sections(lastSection) = ...
- o.pages(lastPage).sections(lastSection).addGraph(varargin{:});
+o.pages(end).sections(end) = ...
+ o.pages(end).sections(end).addGraph(varargin{:});
end
diff --git a/matlab/reports/@report/addSection.m b/matlab/reports/@report/addSection.m
index a0667a5ec..47d2861f5 100644
--- a/matlab/reports/@report/addSection.m
+++ b/matlab/reports/@report/addSection.m
@@ -29,6 +29,5 @@ function o = addSection(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see .
-o.pages(o.pages.numPages()) = ...
- o.pages(o.pages.numPages()).addSection(varargin{:});
+o.pages(end) = o.pages(end).addSection(varargin{:});
end
diff --git a/matlab/reports/@report/addTable.m b/matlab/reports/@report/addTable.m
index 15199b4bd..3de9ddb39 100644
--- a/matlab/reports/@report/addTable.m
+++ b/matlab/reports/@report/addTable.m
@@ -29,8 +29,6 @@ function o = addTable(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see .
-lastPage = o.pages.numPages();
-lastSection = o.pages(lastPage).numSections();
-o.pages(lastPage).sections(lastSection) = ...
- o.pages(lastPage).sections(lastSection).addTable(varargin{:});
+o.pages(end).sections(end) = ...
+ o.pages(end).sections(end).addTable(varargin{:});
end