怎么用matlab画极坐标图
m0=0.1349 θ=0°
m1=0.1257 θ=30°
m2=0.1405 θ=60°
m3=0.1468 θ=90°
m4=0.1399 θ=120°
m5=0.1422 θ=150°
m6=0.1612 θ=180°
m7=0.1578 θ=210°
m8=0.1402 θ=240°
m9=0.1393 θ=270°
m10=0.1228 θ=300°
m11=0.1302 θ=330°
前面为数据值,后面是它在极坐标中的角度。
怎么用极坐标图画出来,然后用平滑的曲线连起来。
最好先把数据能归一化。 展开
1.非封闭曲线,已归一化
clc
clear
t=0:pi/6:(2-1/6)*pi%初始化极角
m=[0.1349 0.1257 0.1405 0.1468 0.1399 0.1422 0.1612 0.1578 0.1402 0.1393 0.1228 0.1302];%初始化矢径
mm=mapminmax(m,0,1);%矢径数据归一化,归一化函数可以根据需求选取
polar(t,mm,'-');
2.封闭曲线,已归一化
clc
clear
t=0:pi/6:(2-1/6)*pi;%初始化极角
m=[0.1349 0.1257 0.1405 0.1468 0.1399 0.1422 0.1612 0.1578 0.1402 0.1393 0.1228 0.1302];%初始化矢径
mm=mapminmax(m,0,1);%矢径数据归一化,归一化函数可以根据需求选取
t=[t,t(1)];
mm=[mm,mm(1)];
polar(t,mm,'-');
这样可以了吗?
Basically, there are two ways to visualise the polar dataset provided above! I will start from the straightforward way in which the data is plotted in polar coordinates directly, to the alternative way in which the data is plotted in Cartesian coordinates instead.
- Firstly, you need to create two arrays which store the polar point consisting of theta and rho seperately, as follow:
theta = 0.0 : 30.0 : 330.0;
rho = [ 0.1349, 0.1257, 0.1405, 0.1468, 0.1399, 0.1422, 0.1612, 0.1578, 0.1402, 0.1393, 0.1228, 0.1302 ];
- Plot line in polar coordinates
polarplot( deg2rad(theta), rho );
- Plot line in Cartesian coordinates
[ x, y ] = pol2cart( deg2rad(theta), rho );
plot( x, y );
Personally, the second plot is easier in visualisation but the transformation from polar coordinates to Cartesian ones must be made after the initialisation of variables.
polar(phase, amp, ' ')
-----------------------------------------------------------------------------------------------------------------------
%%%%%%%%%%%%%%%%%%%%%
%plot your figure before
%%%%%%%%%%%%%%%%%%%%%
% figure resize
set(gcf,'Position',[100 100 260 220]);
set(gca,'Position',[.13 .17 .80 .74]);
figure_FontSize=8;
set(get(gca,'XLabel'),'FontSize',figure_FontSize,'Vertical','top');
set(get(gca,'YLabel'),'FontSize',figure_FontSize,'Vertical','middle');
set(findobj('FontSize',10),'FontSize',figure_FontSize);
set(findobj(get(gca,'Children'),'LineWidth',0.5),'LineWidth',2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
解释:
set(gcf,'Position',[100 100 260 220]);
这句是设置绘图的大小,不需要到word里再调整大小。我给的参数,图的大小是7cm
set(gca,'Position',[.13 .17 .80 .74]);
这句是设置xy轴在图片中占的比例,可能需要自己微调。
figure_FontSize=8;
set(get(gca,'XLabel'),'FontSize',figure_FontSize,'Vertical','top');
set(get(gca,'YLabel'),'FontSize',figure_FontSize,'Vertical','middle');
set(findobj('FontSize',10),'FontSize',figure_FontSize);
这4句是将字体大小改为8号字,在小图里很清晰
set(findobj(get(gca,'Children'),'LineWidth',0.5),'LineWidth',2);
这句是将线宽改为2
plot(1:T, pos, 'color', [0 0 0], 'LineWidth', 2);
hold on;
plot(1:T, B(:, i), 'color', [0 1 0], 'LineWidth', 2);
plot(1:T, G(:, i), 'color', [0 0 1], 'LineWidth', 2);
plot(1:T, R(:, i), 'color', [1 0 0], 'LineWidth', 2);
xlabel('Time');
ylabel('Position');
axis([1 200 -0.05 0.15])
legend('True state', 'Bayes', 'Particle filter', 'Heddge filter', 'Location','NorthWest');
images_fname = [folder '/images/' sprintf('demo1_sigma_%.3f_rho_%.3f_alpha_%.3f.eps',sigma_o, rho, alpha)];
% print('-r80','-dpng',images_fname);
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperPosition', [0.25 2.5 8 4]); % 输出大小由后面两个数确定,原来的输出大小是8 6
print('-r300', '-depsc2', images_fname);
m=[0.1349 0.1257 0.1405 0.1468 0.1399 0.1422 0.1612 0.1578 0.1402 0.1393 0.12228 0.1302];
polar(theta,m)
zoom on
这一个运行一下你看看行不