diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
 
 pandoc-plot uses [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
 
+## Release 1.2.3
+
+* Fixed an issue where MATLAB figures were not being saved in the right location (#27).
+* Releases are now completely taken care of via Github actions.
+
 ## Release 1.2.2
 
 * Executables are now built using GHC 9.0.1
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -36,8 +36,17 @@
 pandoc --filter pandoc-plot input.md --output output.html
 ```
 
-*Note that pandoc-plot only works with pandoc \>= 2.11 because of some
-breaking changes in pandoc’s API.*
+The resulting `output.html` looks like this:
+
+```html
+<h1 id="my-document">My document</h1>
+
+<p>This is a paragraph.</p>
+
+<figure>
+<img src="plots\9671478262050082276.png" />
+</figure>
+```
 
 ## Supported toolkits
 
diff --git a/pandoc-plot.cabal b/pandoc-plot.cabal
--- a/pandoc-plot.cabal
+++ b/pandoc-plot.cabal
@@ -1,6 +1,6 @@
 cabal-version:  2.2
 name:           pandoc-plot
-version:        1.2.2
+version:        1.2.3
 synopsis:       A Pandoc filter to include figures generated from code blocks using your plotting toolkit of choice.
 description:    A Pandoc filter to include figures generated from code blocks. 
                 Keep the document and code in the same location. Output is 
diff --git a/src/Text/Pandoc/Filter/Plot/Monad/Types.hs b/src/Text/Pandoc/Filter/Plot/Monad/Types.hs
--- a/src/Text/Pandoc/Filter/Plot/Monad/Types.hs
+++ b/src/Text/Pandoc/Filter/Plot/Monad/Types.hs
@@ -160,7 +160,7 @@
 inclusionKeys :: [InclusionKey]
 inclusionKeys = enumFromTo (minBound :: InclusionKey) maxBound
 
--- | Datatype containing all parameters required to run pandoc-plot.
+-- | Datatype containing all parameters required to specify a figure.
 --
 -- It is assumed that once a @FigureSpec@ has been created, no configuration
 -- can overload it; hence, a @FigureSpec@ completely encodes a particular figure.
@@ -256,7 +256,7 @@
     oScriptPath :: FilePath,
     -- | Figure output path
     oFigurePath :: FilePath,
-    -- | Current working directory (used for PlantUML)
+    -- | Current working directory
     oCWD :: FilePath
   }
 
diff --git a/src/Text/Pandoc/Filter/Plot/Renderers/Matlab.hs b/src/Text/Pandoc/Filter/Plot/Renderers/Matlab.hs
--- a/src/Text/Pandoc/Filter/Plot/Renderers/Matlab.hs
+++ b/src/Text/Pandoc/Filter/Plot/Renderers/Matlab.hs
@@ -48,14 +48,20 @@
 matlabSupportedSaveFormats = [PNG, PDF, SVG, JPG, EPS, GIF, TIF]
 
 matlabCommand :: Text -> Text -> OutputSpec -> Text
-matlabCommand cmdargs exe OutputSpec {..} = [st|#{exe} #{cmdargs} -batch "run('#{oScriptPath}')"|]
+matlabCommand cmdargs exe OutputSpec {..} = 
+  -- The MATLAB 'run' function will switch to the directory where the script
+  -- is located before executing the script. Therefore, we first save the current
+  -- working directory in the variable 'pandoc_plot_cwd' so that we can use it 
+  -- when exporting the figure
+  [st|#{exe} #{cmdargs} -sd '#{oCWD}' -noFigureWindows -batch "pandoc_plot_cwd=pwd; run('#{oScriptPath}')"|]
 
 -- On Windows at least, "matlab -help"  actually returns -1, even though the
 -- help text is shown successfully!
 -- Therefore, we cannot rely on this behavior to know if matlab is present,
 -- like other toolkits.
 matlabAvailable :: PlotM Bool
-matlabAvailable = asksConfig matlabExe >>= (\exe -> liftIO $ existsOnPath (exe <> exeExtension))
+matlabAvailable = 
+  asksConfig matlabExe >>= (\exe -> liftIO $ existsOnPath (exe <> exeExtension))
 
 matlabCapture :: FigureSpec -> FilePath -> Script
 matlabCapture = appendCapture matlabCaptureFragment
@@ -63,9 +69,15 @@
 matlabCaptureFragment :: FigureSpec -> FilePath -> Script
 matlabCaptureFragment FigureSpec {..} fname =
   [st|
+if java.io.File('#{fname}').isAbsolute() > 0
+  exportpath = '#{fname}';
+else
+  exportpath = fullfile(pandoc_plot_cwd, '#{fname}');
+end
+
 if exist("exportgraphics")>0
-    exportgraphics(gcf, '#{fname}', 'Resolution', #{dpi});
+    exportgraphics(gcf, exportpath, 'Resolution', #{dpi});
 else
-    saveas(gcf, '#{fname}');
+    saveas(gcf, exportpath);
 end
 |]
diff --git a/stack.yaml b/stack.yaml
--- a/stack.yaml
+++ b/stack.yaml
@@ -5,11 +5,11 @@
 - .
 
 extra-deps:
-- pandoc-2.14
+- pandoc-2.14.0.1
 - hslua-module-path-0.1.0.1@sha256:1fe319f18315618491260c912e85b6f73e406499c8fe2fa505e59036a4ff78fd,2502
 - citeproc-0.4@sha256:e198157aec60dbce1e6c1e29592ec6ded69ee5a79ea6645164356bd89458953e,5602
 - commonmark-0.2@sha256:ee873331ff496060dd9becdfaf7f1f4e0fd0688463f5d1f61481a60ed661af45,3426
-- commonmark-extensions-0.2.1.1@sha256:447bda074904ea765c51c73eeb086bbcff936d984366330f9f8506afeefc5ee5,3486
+- commonmark-extensions-0.2.1.2
 - commonmark-pandoc-0.2.1@sha256:7c5db787c15c7a80aa66f5874023386e9b07c134ce24ef9f3aaebe9f52b6f817,1151
 - haddock-library-1.10.0@sha256:2a6c239da9225951a5d837e1ce373faeeae60d1345c78dd0a0b0f29df30c4fe9,4098 
 - jira-wiki-markup-1.4.0@sha256:2fdb7b50bd270d7d388b31df1c746c2864326b68bdd44045323c4f81fd6d5283,3851 
