Skip to content

Commit

Permalink
Plot net power
Browse files Browse the repository at this point in the history
  • Loading branch information
jtgrasb committed Aug 22, 2023
1 parent a563916 commit b3ec972
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Controls/ReactiveWithPTO/userDefinedFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
set(findall(gcf,'type','axes'),'fontsize',16)
xlabel('Time (s)')
ylabel('Power (W)')
title('Electric Power')
title('Electrical Power')
grid on

% Calculate averages to make sure results line up:
Expand All @@ -85,3 +85,18 @@
meanElecPower = mean(output.ptoSim.elecPower(startInd:endInd))
meanVIPower = mean(output.ptoSim.current(startInd:endInd).*output.ptoSim.voltage(startInd:endInd))
meanI2RLosses = mean(output.ptoSim.I2RLosses(startInd:endInd))

figure()
labels = categorical({'Controller (Ideal)','Mechanical (Drivetrain)','Electrical (Generator)'});
labels = reordercats(labels,{'Controller (Ideal)','Mechanical (Drivetrain)','Electrical (Generator)'});
values = [meanControllerPower,meanMechPower,meanElecPower]/1000;
b = bar(labels, values,'FaceColor',[.4 .8 .2]);
ylabel('Power (kW)')
xtickangle(45)

b.FaceColor = 'flat';
for ii = 1:length(values)
if values(ii) > 0
b.CData(ii,:) = [.8 .2 .2];
end
end

0 comments on commit b3ec972

Please sign in to comment.