From 10649d7e568f9a261e7157417cf26de53cc97ef8 Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Wed, 13 Mar 2024 11:01:17 +0100
Subject: [PATCH] fix(Polar): issue with aoa interpolation

---
 +af_tools/@Polar/interppolar.m | 7 ++++---
 CHANGELOG.md                   | 9 ++++++++-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/+af_tools/@Polar/interppolar.m b/+af_tools/@Polar/interppolar.m
index 3b8d661..620800e 100644
--- a/+af_tools/@Polar/interppolar.m
+++ b/+af_tools/@Polar/interppolar.m
@@ -96,15 +96,16 @@ function self = interppolar(Polar1, Polar2, weightPolar2)
     self.nCrit = Polar1.nCrit;
 
     % Interpolate the angle of attack, cl, cd and cm using the base polars
-    if Polar1.aoa ~= Polar2.aoa
+    if numel(Polar1.aoa(:, 1)) ~= numel(Polar2.aoa(:, 1)) || ...
+            any(Polar1.aoa(:, 1) ~= Polar2.aoa(:, 1))
         % Reinterpolate the original polars so they share the same range of AOA.
         aoaMin = min(min(Polar1.aoa(:, 1)), min(Polar2.aoa(:, 1)));
         aoaMax = max(max(Polar1.aoa(:, 1)), max(Polar2.aoa(:, 1)));
         aoaStep = min(diff(Polar1.aoa(1:2, 1)), diff(Polar2.aoa(1:2, 1)));
         aoaVect = aoaMin:aoaStep:aoaMax;
 
-        aoa1 = repmapt(aoaVect', 1, nPolars);
-        aoa2 = repmapt(aoaVect', 1, nPolars);
+        aoa1 = repmat(aoaVect', 1, nPolars);
+        aoa2 = repmat(aoaVect', 1, nPolars);
         cl1 = interp1(Polar1.aoa(:, 1), Polar1.cl, aoaVect');
         cl2 = interp1(Polar2.aoa(:, 1), Polar2.cl, aoaVect');
         cd1 = interp1(Polar1.aoa(:, 1), Polar1.cd, aoaVect');
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70f8f80..925b257 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
+## [4.4.1] - 2024-03-13
+
+### Fixed
+
+- Issue with interpolation of polars between polars with different range of AOA
+
 ## [4.4.0] - 2024-03-13
 
 ### Added
@@ -152,7 +158,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - Initial release
 
-[Unreleased]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/v4.4.0...master
+[Unreleased]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/v4.4.1...master
+[4.4.1]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/4.4.0...v4.4.1
 [4.4.0]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/4.3.0...v4.4.0
 [4.3.0]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/4.2.1...v4.3.0
 [4.2.1]: https://gitlab.uliege.be/am-dept/matlab_airfoil_toolbox/-/compare/4.2.0...v4.2.1
-- 
GitLab