From eeb8cc2f655d06e2841a20f3c6fcb232bfd9aeb1 Mon Sep 17 00:00:00 2001
From: Thomas Lambert <t.lambert@uliege.be>
Date: Wed, 20 Sep 2023 13:13:20 +0200
Subject: [PATCH] fix(Result): display op pts for multi-rotors (closes #15)

---
 src/classes/@Result/Result.m | 7 +++++++
 src/rotare.m                 | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/classes/@Result/Result.m b/src/classes/@Result/Result.m
index 91d79f5..0e71c09 100644
--- a/src/classes/@Result/Result.m
+++ b/src/classes/@Result/Result.m
@@ -81,6 +81,13 @@ classdef Result < handle
             % Note: A bug in Matlab prevents the use of variable names when size checks are added
             % in the property definition. See: https://stackoverflow.com/q/48423003
             self.operPts = val;
+
+            % Properly name and group operating points for multi rotors
+            % Must merge in that order to have correct indexes
+            nRots = (size(val, 2) - 2) / 2;
+            self.operPts = mergevars(self.operPts, 3 + nRots:size(val, 2));
+            self.operPts = mergevars(self.operPts, 3:3 + nRots - 1);
+
             self.operPts.Properties.VariableNames = {'altitude', 'speed', 'rpm', 'collective'};
 
         end
diff --git a/src/rotare.m b/src/rotare.m
index 166a186..7ef0451 100644
--- a/src/rotare.m
+++ b/src/rotare.m
@@ -141,7 +141,8 @@ function [Results] = rotare(configFile)
 
                         % Table that identifies the operating point for future reuse
                         operPoints(iOperPoint, :) = [Uop.altitude(iAlt), Uop.speed(iSpeed), ...
-                                                     Uop.rpm(i, iRpm), Uop.collective(i, iColl)];
+                                                     [Uop.rpm(:, iRpm)'], ...
+                                                     [Uop.collective(:, iColl)']];
 
                         iOperPoint = iOperPoint + 1;
 
-- 
GitLab