%WIND_ROSE Wind rose of direction and intensity
% % Syntax: % [HANDLES,DATA] = WIND_ROSE(D,I,VARARGIN)
%
% Inputs: % D Directions % I Intensities % VARARGIN: % -dtype, type of input directions D, standard or meteo, % if meteo, the conversion dnew=mod(-90-D,360) is done; % if not meteo, standard is used (default) % -n, number of D subdivisons % -di, intensities subdivisons, default is automatic % -ci, percentage circles to draw, default is automatic % -labtitle, main title % -lablegend, legend title % -cmap, colormap [jet] % -colors, to use instead of colormap, for each di % -quad, Quadrant to show percentages [1] % -ri, empty internal radius, relative to size of higher % percentage [1/30] % -legtype, legend type: 1, continuous, 2, separated boxes [2] % -bcolor, full rectangle border color ['none'] % -lcolor, line colors for axes and circles ['k'] % -percbg, percentage labels bg ['w'] % -ax, to place wind rose on pervious axes, the input for ax % must be [theax x y width], where theax is the previous % axes, x and y are the location and width is the wind % rose width relative to theax width (default=1/5) % -parent, by default a new axes is created unless parent is % given, ex, parent may be a subplot % -iflip, flip the intensities as they go outward radially, ie, % highest values are placed nearest the origin [{0} 1] % -inorm, normalize intensities, means all angles will have 100% % -incout, if 0, data outside di limits will not be used [0 {1}]
%
% Output: % HANDLES Handles of all lines, fills, texts % DATA Wind rose occurences per direction and intensity
%
% Examle: % d=0:10:350; % D=[]; % V=[]; % for i=1:length(d) % n=d(i)/10; % D=[D ones(1,n)*d(i)]; % V=[V 1:n]; % end
%
% figure % wind_rose(D,V)
%
% figure % wind_rose(D,V,'iflip',1)
%
% figure % wind_rose(D,V,'ci',[1 2 7],'dtype','meteo')
%
% % place it on a previous axes: % ax=axes; % plot(lon,lat) % wind_rose(D,V,'ax',[ax x y 1/3])
%
% MMA 26-11-2007, mma@odyle.net
%
% IEO, Instituto Español de Oceanografía % La Coruña, España
% 10-12-2007 - Added varargin ci and n (nAngles removed as input) % 17-12-2007 - Added varargin ax, colors % 22-02-2008 - Added varargin dtype % 08-05-2008 - Bug fix (bar at dir=0 could be incorrect in some cases) % 14-05-2008 - Added varargin iflip % 16-06-2008 - Added varargin parent % 10-06-2009 - Added varargin incout % 27-04-2010 - Added output DATA % 17-06-2010 - Bug fix (E(i,end)=length(find(b>=Ag(end-1))), % previously was ...b>Ag...). So the percentages where % wrong only when using intensities equal to the lower % value of the highest intensity subdivision, basically % an academic case.
handles=[];
% varargin options:
dtype='standard';
nAngles=36;
ri=1/30;
quad=1;
legType=2;
percBg='w';
titStr='';
legStr='';
cmap=jet;
colors=[];
Ag=[]; % intensity subdivs.
ci=[]; % percentage circles
lineColors='k';
borderColor='none';
onAxes=false;
iflip=0;
inorm=0;
parent=0;
IncHiLow=1; % include values higher and lower that the limits of Ag.
% check if has values higher or lower than the Ag limits
hasH=length(find(F>Ag(end)));
hasL=length(find(F<Ag(1)));
% calc number of percentage circles to draw: ifisempty(ci) if inorm
ci=[255075];
g=120;
ncircles=3;
else
dcircles=[125101520253050];
ncircles=3;
d=abs(1./(dcircles/max(b))-ncircles);
i=find(d==min(d));
d=dcircles(i(1));
if d*ncircles<max(b)
ncircles=ncircles+1;
end
ci=[1:ncircles]*d;
g=ncircles*d;
end else
ncircles=length(ci);
g=max(max(ci),max(b));
end
% plot axes, percentage circles and percent. data: if parent
wrAx=parent;
set(wrAx,'units','normalized');
else
wrAx=axes('units','normalized');
end
ri=g*ri;
handles(end+1)=fill([-rs*g rl*g rl*g -rs*g],[-rs*g -rs*g rs*g rs*g],'w',...
'EdgeColor',borderColor);
if onAxes
set(handles(end),'facecolor','none') end hold on
handles(end+1)=plot([-g-ri -ri nan ri g+ri nan00nan00],... [00nan00nan -g-ri -ri nan ri g+ri],':','color',lineColors);
t0=[0:360]*pi/180;
labs=[];
Ang=[1/43/45/47/4]*pi;
Valign={'top' 'top' 'bottom' 'bottom'};
Halign={'right' 'left' 'left' 'right'};
for i=1:ncircles
x=(ci(i)+ri)*cos(t0);
y=(ci(i)+ri)*sin(t0);
% uistack has problems in some matlab versions, so:
%uistack(labs,'top')
%uistack(circles,'top')
ch=get(wrAx,'children');
if inorm
% only bring circles up in inorm case. for i=1:length(circles)
ch(ch==circles(i))=[]; ch=[circles(i); ch];
end end for i=1:length(labs)
ch(ch==labs(i))=[]; ch=[labs(i); ch];
end set(wrAx,'children',ch);
% N S E W labels:
bg='none';
args={'BackgroundColor',bg,'FontSize',8};
h(1)=text(-g-ri, 0,'WEST', 'VerticalAlignment','top', 'HorizontalAlignment','left', args{:});
h(2)=text( g+ri, 0,'EAST', 'VerticalAlignment','top', 'HorizontalAlignment','right',args{:});
h(3)=text(0,-g-ri,'SOUTH','VerticalAlignment','bottom','HorizontalAlignment','left', args{:});
h(4)=text(0, g+ri,'NORTH','VerticalAlignment','top', 'HorizontalAlignment','left', args{:});
handles=[handles h];
if1 % place at centre of the wr, not the bottom left corner:
ax2Xlim=get(ax2,'xlim');
ax2Ylim=get(ax2,'ylim');
dx=(0-ax2Xlim(1))/diff(ax2Xlim)*pax2(3);
dy=(0-ax2Ylim(1))/diff(ax2Ylim)*pax2(4);
x_ax2=x_ax2-dx;
y_ax2=y_ax2-dy;
pax2=[x_ax2 y_ax2 width height];
end set(ax2,'position',pax2)
function cor = caxcolor(val,cax,cmap)
%CAXCOLOR Caxiscolorfor value
% Find the color for a given value in a colormap.
%
% Syntax: % COLOR = CAXCOLOR(VALUE,CAXIS,COLORMAP)
%
% Inputs: % VALUE % CAXIS Default is current caxis % COLORMAP Default is current colormap
%
% Output: % COLOR RGB color vector
%
% Example: % figure % pcolor(peaks) % color=caxcolor(0); % set(gcf,'color',color)
%
% MMA 28-5-2007, martinho@fis.ua.pt
% Department of Physics % University of Aveiro, Portugal
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.