Matlab: Polarplot Achsenbeschriftungs- und Skalierfunktion

Polar-Plots

(English) Bei Polar-Plots mit Matlab stößt man auf ein Problem, da mit MATLABTIKZ die Achsenbeschriftung nicht übernommen wird. Dies kann man mit der von mir programmierten Funktion jedoch lösen:

polartikzlabel(angleticks,abs,ticks,absdeg,anglestr,absstr,round1)

Hierbei gibt "angleticks" die Anzahl der Unterteilungen der Winkel an, "abs" den Radius des Polarplots an, "ticks" die Anzahl der Aufteilungsschritte der Radienskala, "absdeg" den Winkel der Radienbeschriftungsskala an.
"anglestr" gibt die Beschriftung der Winkelachse an und "absstr" die Beschriftung der Radialachse an. "round1" gibt an, wie viele Nachkommestellen die Beschriftungen haben sollen.

Dies kann wie folgt aussehen: polartikzlabel(5,1,6,40,'angle','radial',3)

Hier der Quellcode:

function polargrid(angleticks,abs,ticks,absdeg,anglestr,absstr,round1)
%angleticks set the number of ticks in equidistant angles.
%abs set the radius of the polarplot.
%ticks set the number of ticks in equidistant radialskale.
%absdeg set the degree of the radialaxis.
%anglestr set the labeling of the angleaxis.
%absstr set the labeling of the radialaxis.
%the number of positions behind the point.

  
%Delete the text
delete(findall(gcf,'type','text'));

%Delete the grid
set(0,'ShowHiddenHandles','on')
set(findobj(findobj(get(gca,'Children'),'Type','Line'),'LineStyle','-'),{'Visible'},{'off'});
hold on;
%Declare the variables
value1=360/angleticks;
value2=abs/ticks;
if nargin < 5
    anglestr = 'angle';
    absstr = 'radial';
end
%round the labels
if nargin < 7
    round1 = 2;
end
round1 = (10)^(round1);
angles =round([0:value1*round1:(360-value1)*round1])/(round1);
rho = round([0:value2*round1:abs*round1])/(round1)

n=numel(rho);
rad=rho(n)+rho(n)/10;

%Draw the angle-scale
amount = numel(angles);
X = [zeros(amount,1), rho(n)*cos(angles(1:amount)'./180*pi)];
Y = [zeros(amount,1), rho(n)*sin(angles(1:amount)'./180*pi)];

plot(X',Y','Color',[0.8 0.8 0.8]);

%Draw the radial-scale
anglegrid = [0:pi/100:2*pi];
Xgrid = rho'* cos(anglegrid);
Ygrid = rho'* sin(anglegrid);
plot(Xgrid',Ygrid','Color',[0.8 0.8 0.8]);


%Draw the skalevalues
Xangle = rad.*cos(angles./180*pi)-abs/20;
Yangle = rad.*sin(angles./180*pi);
text(Xangle,Yangle,num2cell(angles));

Xrho = rho*cos(absdeg/180*pi);
Yrho = rho*sin(absdeg/180*pi)+sin(absdeg/180*pi)*abs/10;
text(Xrho,Yrho,num2cell(rho));

%Write the labels
text(1.1*abs*cos(absdeg/180*pi),1.3*abs*sin(absdeg/180*pi),absstr);
text(abs+abs/5,0,anglestr);


Kommentare

Beliebte Posts aus diesem Blog

Matlab: Fehlergeraden

Matlab: 3D Kartesisches Grid, Vektoren mit Transformation/Rotation

Matlab: Farbspektrum für Plots