clc
clear
close all
%% calculations (fake)
T = 10;
f = 1/T;
w = 2*pi*f;
t = 0:0.01:10;
% velocity
v = cos(w*t);
% PTO force
fu.cc = -1*cos(w*t + 0.1*2*pi);
Fumax = 0.75*max(fu.cc);
fu.ps = arrayfun(@(x) sign(x) * min([abs(x),Fumax]), fu.cc);
fu.p = -0.5*v;
% power
fn = fields(fu);
for ii = 1:length(fn)
if ii < 3
vv = v*1.1;
else
vv = v;
end
pow.(fn{ii}) = vv .* fu.(fn{ii});
avgPow.(fn{ii}) = mean(pow.(fn{ii}));
end
%% plotting
figure('color','white')
ax(1) = subplot(3,1,1);
hold on
grid on
plot(t,v,'k')
set(gca,'XTick',0:2.5:10)
set(gca,'XTickLabels',[])
set(gca,'YTick',[-0.5, 0, 0.5])
set(gca,'YTickLabels',[])
ylabel('Velocity, $v$','Interpreter','latex')
ax(2) = subplot(3,1,2);
hold on
grid on
for ii = 1:length(fn)
plot(ax(2),t,fu.(fn{ii}), 'DisplayName', fn{ii})
end
legend('location','best','Interpreter','latex')
set(gca,'XTickLabels',[])
set(gca,'XTick',0:2.5:10)
set(gca,'YTickLabels',{'$F^{max}_{pto}$','0','$F^{max}_{pto}$'})
set(gca,'YTick',[-Fumax, 0, Fumax])
set(gca,'TickLabelInterpreter','latex')
ylabel('PTO force, $F_{pto}$','Interpreter','latex')
ax(3) = subplot(3,1,3);
hold on
grid on
for ii = 1:length(fn)
plot(ax(3),t,pow.(fn{ii}), 'DisplayName', fn{ii})
end
ax(3).ColorOrderIndex = 1;
for ii = 1:length(fn)
plot(ax(3),xlim,avgPow.(fn{ii})*ones(2,1), '--',...
'DisplayName', fn{ii})
end
set(gca,'XTick',0:2.5:10)
set(gca,'XTickLabels',[])
set(gca,'YTickLabels',{'','','0'})
linkaxes(ax,'x')
xlabel('Time, $t$','Interpreter','latex')
ylabel('Power','Interpreter','latex')
export_fig('exampleForMat.png')
savefig('exampleForMat.fig')
It's a common challenge for users to understand the difference between
P,PS, andCC. I put together an example below that tries to illustrate this. I propose that we