function [figure_handle,count,speeds,directions,Table] = WindRose(direction,speed,varargin)
%% WindRose
% Draw a Wind Rose knowing direction and speed
%
% [figure_handle,count,speeds,directions,Table] = WindRose(direction,speed);
% [figure_handle,count,speeds,directions,Table] = WindRose(direction,speed,'parameter1',value1,...);
%
% figure_handle is the handle of the figure containing the chart
% count is the frequency for each speed (ncolumns = nspeeds) and for each direction (nrows = ndirections).
% speeds is a 1 by n vector containing the values for the speed intervals
% directions is a m by 1 vector containing the values in which direction intervals are centered
% Table is a (4+m) by (3+m) cell array (excel-ready), containing Frequencies for each direction and for each speed.
%
% User can specify direction angle meaning North and East winds, so
% the graphs is shown in the desired reference
%
% % Example:
% %----------------------------------------------------------------
% d = 360 * rand(10000,1); % My reference is North = 0º, East = 90º.
% v = 30*rand(10000,1);
%
% % Default notation with several input arguments
% [figure_handle,count,speeds,directions,Table] = WindRose(d,v,'anglenorth',0,'angleeast',90,'labels',{'N (0°)','S (180°)','E (90°)','W (270°)'},'freqlabelangle',45);
%
% % All the wind rose options into a cell array, so function call can be simplified
% Properties = {'anglenorth',0,'angleeast',90,'labels',{'N (0°)','S (180°)','E (90°)','W (270°)'},'freqlabelangle',45};
% [figure_handle2,count2,speeds2,directions2,Table2] = WindRose(d,v,Properties);
%
% % All the wind rose options into a structure, so function call can be simplified.
% Options.AngleNorth = 0;
% Options.AngleEast = 90;
% Options.Labels = {'N (0°)','S (180°)','E (90°)','W (270°)'};
% Options.FreqLabelAngle = 45;
% [figure_handle3,count3,speeds3,directions3,Table3] = WindRose(d,v,Options);
%
%
%
% PARAMETER CLASS DEFAULT VALUE DESCRIPTION
%------------------------------------------------------------------------------------------------------------------------------------------------------------
% 'centeredin0' Logical. true Is first angular bin centered in 0 (-5 to 5)? -> CeteredIn0 = true // or does it start in 0 (0 to 10)? -> CeteredIn0 = false.
% 'ndirections' Numeric. 36 Number of direction bins (subdivisions) to be shown.
% 'freqround' Numeric. 1 Maximum frquency value will be rounded to the first higher whole multiple of FrequenciesRound. Only applies if 'maxfrequency' is specified.
% 'nfreq' Numeric. 5 Draw this number of circles indicating frequency.
% 'speedround' Numeric. [] (auto) Maximum wind speed will be rounded to the first higher whole multiple of WindSpeedRound.
% 'nspeeds' Numeric. [] (auto) or 6 Draw this number of windspeeds subdivisions (bins). Default is 6 if 'speedround' is specified. Otherwise, default is automatic.
% 'maxfrequency' Numeric. [] (auto) Set the value of the maximum frequency circle to be displayed. Be careful, because bins radius keep the original size.
% 'freqlabelangle' Numeric/String. [] (auto) Angle in which frequecy labels are shown. If this value is empty, frequency labels will NOT be shown. Trigonometric reference. 0=Right, 90=Up. You can use 'auto' to show them in the optimal position.
% 'titlestring' Cell/String. {'Wind Rose';' '} Figure title. It is recommended to include an empty line below the main string.
% 'lablegend' String. 'Wind speeds in m/s' String that will appear at the top of the legend. Can be empty.
% 'legendvariable' String. 'W_S' Variable abbreviation that appears inside the legend. You can use TeX sequences.
% 'cmap' Numeric/String. 'parlua/jet' N×3 RGB map or String with the name of a colormap function. If the string option is chosen and if you put inv before the name of the colormap funcion, colors will be flipped (e.g. 'invjet', 'invautum', 'invbone', 'invparula', ...). Use any of the built-in functions (autumn, bone, colorcube, cool, copper, flag, gray, hot, hsv, jet, lines, pink, prism, spring, summer, white, winter). See doc colormap for more information.
% 'height' Numeric. 2/3*screensize Figure inner height in pixels. Default is 2/3 of minimum window dimension;
% 'width' Numeric. 2/3*screensize Figure inner width in pixels. Default is 2/3 of minimum window dimension;
% 'figcolor' Color Code. 'w' Figure color, any admitted matlab color format. Default is white. If 'axes' is specified, figure color will be used as background color.
% 'textcolor' Color Code. 'k' Text and axis color, any admitted matlab color format. Default is black.
% 'labels' CellString {'N','E','S','W'} Specify North South East West in a cell array of strings. Now you can specify as many as you want, for example: {'N','NE','E','SE','S','SW','W','NW'}
% 'labelnorth' Cell/String. 'N' Label to indicate North. Be careful if you specify 'labels' and 'labelnorth'. Last parameter specified will be the one used.
% 'labelsouth' Cell/String. 'S' Label to indicate South. Be careful if you specify 'labels' and 'labelsouth'. Last parameter specified will be the one used.
% 'labeleast' Cell/String. 'E' Label to indicate East. Be careful if you specify 'labels' and 'labeleast' . Last parameter specified will be the one used.
% 'labelwest' Cell/String. 'W' Label to indicate West. Be careful if you specify 'labels' and 'labelwest' . Last parameter specified will be the one used.
% 'titlefontweight' String. 'bold' Title font weight. You can use 'normal','bold','light','demi'
% 'anglenorth' Numeric. 90 Direction angle meaning North wind. Default is 90 for North (trigonometric reference). If you specify 'north' angle, you need to specify 'east' angle, so the script knows how angles are referenced.
% 'angleeast' Numeric. 0 Direction angle meaning East wind. Default is 0 for East (counterclockwise). If you specify 'east' angle, you need to specify 'north' angle, so the script knows how angles are referenced.
% 'min_radius' Numeric. 1/15 Minimum radius of the wind rose, relative to the maximum frequency radius. An empty circle of this size appears if greater than 0.
% 'legendtype' Numeric. 2 Legend type continuous = 1 (colorbar), separated boxes = 2 (legend)
% 'toolbar' String. 'figure' Choose if you want to show figure's toolbar ('figure') or hide it ('none')
% 'menubar' String. 'figure' Choose if you want to show figure's menubar ('figure') or hide it ('none')
% 'colors' Num Array. [] If 'nspeeds' has been specified, colors can be a nspeeds-by-3 array (R G B), containing the color for each speed (lowest in first row, highest in last row). Color components must be in range 0 to 1
评论2