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;endGZi = 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 offend
MATLAB: Looking at the graph, there should be 3 graphs in the legend, but why are there 5
errorfigure
Best Answer