Skip to content
Snippets Groups Projects
Verified Commit 5876a34b authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

feat(Result): add support all perf in plot

parent 0494a9bf
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,7 @@ function plotperf(self, varargin)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Defaults and constants
DEF.ALLOWED_PROPERTIES = {'cT', 'cQ', 'cP'};
DEF.ALLOWED_PROPERTIES = {'thrust', 'torque', 'power', 'eff', 'cT', 'cQ', 'cP'};
DEF.allowed_oper = self.operPts.Properties.VariableNames;
DEF.ALLOWED_SOLVERS = {'leishman', 'indfact', 'indvel', 'stahlhut'};
......@@ -56,14 +56,15 @@ function plotperf(self, varargin)
figure('Name', 'Rotor performance');
end
filtered = filtertable(self.summarize, ...
operPt.altitude, operPt.speed, ...
operPt.rpm, operPt.collective);
[filtered, idx] = self.filter(operPt.altitude, operPt.speed, operPt.rpm, operPt.collective);
for iSolv = 1:length(solvers)
perfSolv = sprintf('%s_%s', perf, solvers{iSolv});
plot(filtered.(oper), filtered.(perfSolv), 'DisplayName', solvers{iSolv});
if iSolv == 1
thissolv = solvers{iSolv};
if ~isempty(self.(thissolv))
dataVect = vectorize(filtered.(thissolv), perf);
plot(self.operPts(idx, :).(oper), dataVect, 'DisplayName', solvers{iSolv});
hold on;
end
end
......@@ -84,7 +85,7 @@ function [perf, oper, solvers, operPt, newFig] = parseinputs(DEF, varargin)
addRequired(p, 'speed', valData);
addRequired(p, 'rpm', valData);
addRequired(p, 'collective', valData);
addParameter(p, 'solvers', {'leishman', 'indfact', 'indvel', 'stahlhut'});
addParameter(p, 'solvers', DEF.ALLOWED_SOLVERS);
addParameter(p, 'newFig', false, valLogi);
parse(p, varargin{:});
......@@ -100,18 +101,13 @@ function [perf, oper, solvers, operPt, newFig] = parseinputs(DEF, varargin)
newFig = p.Results.newFig;
end
function filtered = filtertable(inputTable, alt, speed, rpm, coll)
% FILTERTABLE Filter the data with corresponding alt, coll, rpm and speed from the summary table
iAlt = getidx('altitude', alt);
iSpeed = getidx('speed', speed);
iRpm = getidx('rpm', rpm);
iColl = getidx('collective', coll);
function vect = vectorize(struct, prop)
% VECTORIZE Transform struct array into a vector
filtered = inputTable(iAlt & iColl & iRpm & iSpeed, :);
vect = zeros(1, length(struct));
function idx = getidx(type, val)
idx = inputTable.(type) == val | isnan(val);
for i = 1:length(struct)
vect(i) = struct(i).(prop);
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment