From 214cd796dd16df45fd0683f0fc89b2a0aaf95f91 Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Mon, 11 Jul 2022 17:19:47 +0200
Subject: [PATCH] fix(plotpol): issue when missing data

---
 +af_tools/plotpolars.m | 36 ++++++++++++++++++++----------------
 CHANGELOG.md           |  4 +++-
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/+af_tools/plotpolars.m b/+af_tools/plotpolars.m
index 5bdf0cf..8c5d9c9 100644
--- a/+af_tools/plotpolars.m
+++ b/+af_tools/plotpolars.m
@@ -81,15 +81,15 @@ function plotpolars(varargin)
 
     set(0, 'defaultTextInterpreter', 'latex'); % Default interpreter for all plots
 
-    plotsinglepolar(rad2deg(alpha), c_l, '$C_l - \alpha$', '$\alpha$ [deg]', '$C_l$ [-]');
+    plotsinglepolar(rad2deg(alpha), c_l, 'C_l - \alpha', '$\alpha$ [deg]', '$C_l$ [-]');
     if nargin > 2 || nargin <= 1
-        plotsinglepolar(rad2deg(alpha), c_d, '$C_d - \alpha$', '$\alpha$ [deg]', '$C_d$ [-]');
-        plotsinglepolar(rad2deg(alpha), c_l ./ c_d, '$C_l/C_d - \alpha$', '$\alpha$ [deg]', ...
+        plotsinglepolar(rad2deg(alpha), c_d, 'C_d - \alpha', '$\alpha$ [deg]', '$C_d$ [-]');
+        plotsinglepolar(rad2deg(alpha), c_l ./ c_d, 'C_l/C_d - \alpha', '$\alpha$ [deg]', ...
                         '$C_l/C_d$ [-]');
-        plotsinglepolar(c_l, c_d, '$C_d - C_l$', '$C_l$ [-]', '$C_d$ [-]');
+        plotsinglepolar(c_l, c_d, 'C_d - C_l', '$C_l$ [-]', '$C_d$ [-]');
     end
     if nargin > 3 || nargin <= 1
-        plotsinglepolar(rad2deg(alpha), c_m, '$C_m - \alpha$', '$\alpha$ [deg]', '$C_m$ [-]');
+        plotsinglepolar(rad2deg(alpha), c_m, 'C_m - \alpha', '$\alpha$ [deg]', '$C_m$ [-]');
     end
 
 end
@@ -98,21 +98,25 @@ end
 function plotsinglepolar(dataX, dataY, fTitle, fXlabel, fYlabel)
     % PLOTSINGLE Standardize polar plots
 
-    if ~exist('fTitle', 'var')
-        fTitle = '';
-    end
+    if ~isempty(dataX) && ~isempty(dataY)
 
-    figure('PaperUnits', 'inches', 'PaperPosition', [0 0 1280 1024] / 250, 'Name', fTitle);
-    plot(dataX, dataY);
+        if ~exist('fTitle', 'var')
+            fTitle = '';
+        end
 
-    if exist('fXlabel', 'var')
-        xlabel(fXlabel);
-    end
-    if exist('fYlabel', 'var')
-        ylabel(fYlabel);
+        figure('PaperUnits', 'inches', 'PaperPosition', [0 0 1280 1024] / 250, 'Name', fTitle);
+        plot(dataX, dataY);
+
+        if exist('fXlabel', 'var')
+            xlabel(fXlabel);
+        end
+        if exist('fYlabel', 'var')
+            ylabel(fYlabel);
+        end
+
+        setgca();
     end
 
-    setgca();
 end
 
 % --------------------------------------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4205b80..5b27383 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,7 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
-## [4.0.0] 2022-06-09
+- **plotpolar**: fix issue when unavailable data
+
+## [4.0.0] - 2022-06-09
 
 ### Added
 
-- 
GitLab