1.画一张极坐标图
clear
clc
close all
% 生成随机风向和风速数据
num_samples = 100;
wind_directions = randi([0, 360], 1, num_samples)'; % 随机生成0到360度之间的风向
wind_speeds = randi([1, 10], 1, num_samples)'; % 随机生成1到10的风速
% 将风速和风向转换为极坐标坐标系的坐标
theta = deg2rad(wind_directions); % 将角度转换为弧度
rho = wind_speeds;
polaraxes; % 创建极坐标轴
polarplot(theta, rho, 'ro'); % 绘制风速和风向的极坐标图
title( 'Wind Speed and Direction Plot'); % 添加标题
pax=gca;
pax.ThetaDir = 'clockwise'; % 按顺时针方式递增
pax.ThetaZeroLocation = 'top'; % 按顺时针方式递增
pax.FontSize=12; %设置字体大小
pax.FontSizeMode='auto'; %设置字体自动化
2.画一张带有不同参数的极坐标图
clear
clc
close all
Un=zeros(100,1); %
Uw=zeros(100,1); % 西风为正
uz=zeros(100,1);
Un(:,1)=rand(100,1);
Uw(:,1)=rand(100,1);
Umean=sqrt(Un.^2+Uw.^2);
theta_deg = atan2d(Uw,Un)+180;
theta_deg =360-mod(theta_deg+180,360);
theta=theta_deg/360*2*pi;
arrayA=[theta,Umean];
tf1=find(arrayA(:,2)>0.9) %筛选出部分数据
arrayA1=arrayA(tf1,:);
tf2=arrayA(:,2)<0.9; %筛选出部分数据
arrayA2=arrayA(tf2,:);
% 开始画图
polaraxes
polarplot(arrayA1(:,1), arrayA1(:,2), 'ro'); % 绘制风速和风向的极坐标图
hold on
polarplot(arrayA2(:,1), arrayA2(:,2), 'bo');
hold off
%图的标签等
title( 'Wind Speed and Direction Plot'); % 添加标题
pax=gca;
pax.ThetaDir = 'clockwise'; % 按顺时针方式递增
pax.ThetaZeroLocation = 'top'; % 按顺时针方式递增
pax.FontSize=12; %设置字体大小