Looking at the graph, there should be 3 graphs in the legend, but why are there 5?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
SUNGJIN KIM
le 28 Oct 2020
Commenté : Mathieu NOE
le 28 Oct 2020
function [SteadyHeel] = SailCode(stability, KG, GM, downflood)
stability = [0 5 10 ...
85 900; 0 0.308 0.611...
3.249 3.216];
KG = 2.037;
GM = 1.5;
downflood = 55;
heel = stability(1,:);
k = stability(2,:);
GZ = k - KG * sind(heel);
heeli = 0:2.5:heel(end);
if nargin < 4
SteadyHeel = stability, KG, GM, downflood;
end
GZi = spline(heel,GZ,heeli);
GZf = spline(heel,GZ,downflood);
WLO = GZf/cosd(downflood)^1.3; gust = WLO*cosd(heeli).^1.3;
steady = gust/2;
plot(heeli,GZi, 'k-', heeli,gust,'r--',heeli, steady,'g--');
title('Sail-vessel stability according to UK Maritime and Coastguard Agency');
xlabel('Heel angle,deg')
ylabel('Lever arms, m')
legend('GZ', 'Gust wind', 'Steady wind');
axis([0,90,0,2.5])
hold on
plot([ 0 180/pi],[0 GM],'k-');
text(1.5,1.25, ('Angle of steady heel = 35.7719 deg'))
text(heeli(2), 1.02*gust(2), 'WLO');
plot([ downflood downflood ], [ 0 GZf ], 'k-')
text(1.01*downflood, 0.05*GZf, 'Downflooding angle');
hold off
end
0 commentaires
Réponse acceptée
Mathieu NOE
le 28 Oct 2020
hi
i guess the legend will be messed up with hold on / hold off afterwards
i put it at the end and I could get the expected 3 labels in the legend
BTW I was surprised to have a warning : gust and
I couldn't figure the reason for getting a complex output from a real valued vector , so I finally made a work around function (for what it's worth)
% gust = WLO*cosd(heeli).^1.3; % this generates a complex output (??)
gust = mypower(WLO*cosd(heeli),1.3); % this generates a real output (as expected)
steady = gust/2;
plot(heeli,GZi, 'k-', heeli,gust,'r--',heeli, steady,'g--');
title('Sail-vessel stability according to UK Maritime and Coastguard Agency');
xlabel('Heel angle,deg')
ylabel('Lever arms, m')
% legend('GZ', 'Gust wind', 'Steady wind');
axis([0,90,0,2.5])
hold on
plot([ 0 180/pi],[0 GM],'k-');
text(1.5,1.25, ('Angle of steady heel = 35.7719 deg'))
text(heeli(2), 1.02*gust(2), 'WLO');
plot([ downflood downflood ], [ 0 GZf ], 'k-')
text(1.01*downflood, 0.05*GZf, 'Downflooding angle');
hold off
legend('GZ', 'Gust wind', 'Steady wind');
function [y] = mypower(x,a)
ss = sign(x);
y_log = a.*log10(abs(x));
y = ss.*10.^(y_log);
end
1 commentaire
Mathieu NOE
le 28 Oct 2020
sorry
there was a missing part in my sentence :
BTW I was surprised to have a warning : "gust" and "steady" are both complex numbers , which I didn't expect. Reasons ???
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!