Clear Filters
Clear Filters

How to put into equal number of concentric arcs sector (levels) based on the mass flux distribution values?

2 views (last 30 days)
This below code is creating concentric sector (120 deg) plot in irregular spacing patterns (with color) based on mass flux values.
How to make circular concentric arcs into equidistant 8 levels based on the r values (r = 0, 0.05, 0.15,0.25,0.35,0.45,0.55,0.65,0.75)
with mass flux values such that 0.032892022 value for concentric sector 1 (0 to 0.05 m), 0.094299304 for concentric sector 2 (0.05 m to 0.15 m) and so on.....
z1 = [0.032892022, 0.094299304, 0.07752172, 0.0437234, 0.027818958, 0.02382019, 0.020690143, 0.008658787] ; %mass flux values kg/m2.s
n = 120;
r = [0,0.05:0.1:0.75]; %sector radius
theta = deg2rad(0:n);
z1 = [0.032892022, 0.094299304, 0.07752172, 0.0437234, 0.027818958, 0.02382019, 0.020690143, 0.008658787, 0.00]; %mass flux values kg/m2.s
X = cos(theta') * r;
Y = sin(theta') * r;
Z = repmat(z1, [length(theta), 1]);
figure
contourf (X, Y, Z, 5); axis equal
colorbar
shading interp
colormap (jet(100))
%view(20,90)
n = 120;
r = [0,0.05:0.1:0.75]; %sector radius
theta = deg2rad(0:n);
z1 = [0.032892022, 0.094299304, 0.07752172, 0.0437234, 0.027818958, 0.02382019, 0.020690143, 0.008658787, 0.00]; %mass flux values kg/m2.s
X = cos(theta') * r;
Y = sin(theta') * r;
Z = repmat(z1, [length(theta), 1]);
figure
contourf (X, Y, Z, 5); axis equal
colorbar
shading interp
colormap (jet(100))
%view(20,90)

Answers (1)

Maneet Kaur Bagga
Maneet Kaur Bagga on 27 Dec 2023
Hi Raghav,
As per my understanding, to create a polar plot that visualizes mass flux data within a 120-degree sector. The sector is divided into 8 equidistant concentric segments based on given radii. Each segment is colored according to its corresponding mass flux value.
The error which is not producing the desired result is because:
  • The radii are specified with a range from 0 to 0.75 with an increment of 0.1, starting from 0.05 (r = [0,0.05:0.1:0.75];). This creates non-uniform gaps between the radii because the first gap is only 0.05 while the others are 0.1.
  • The z1 array has one more element than the r array, which would cause an error when trying to create the Z matrix with repmat(z1, [length(theta), 1]). The number of mass flux values (z1) should match the number of intervals between the radii, not the number of radii themselves.
  • The "contourf" function is used to create filled contours, but for it to produce a plot with equidistant concentric circles, the Z values must be defined over a grid that reflects the radial symmetry.
Please refer to the modified code below for better understanding:
% Given radii and mass flux values
r = [0, 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75];
z1 = [0.032892022, 0.094299304, 0.07752172, 0.0437234, 0.027818958, 0.02382019, 0.020690143, 0.008658787];
% Define the angle for the 120-degree arc in radians
theta_start = 0; % 0 degrees
theta_end = 2*pi/3; % 120 degrees
n_theta = 100; % Number of angular points (for smoothness of the plot)
% Prepare figure
figure;
hold on;
axis equal;
colormap jet;
% Define the range of angles for the 120-degree arc
theta = linspace(theta_start, theta_end, n_theta);
% Plot each sector
for i = 1:length(z1)
% Define the vertices of the sector within the 120-degree arc
x_inner = r(i) * cos(theta);
y_inner = r(i) * sin(theta);
x_outer = r(i+1) * cos(theta);
y_outer = r(i+1) * sin(theta);
% Combine the vertices to form a closed shape for the sector
x_sector = [x_inner, fliplr(x_outer)];
y_sector = [y_inner, fliplr(y_outer)];
% Fill the sector with the appropriate color
fill(x_sector, y_sector, z1(i), 'EdgeColor', 'k'); % Add black edge color to distinguish sectors
end
% Add a line to indicate the segment on the x-axis
line([0, r(end)], [0, 0], 'Color', 'k', 'LineWidth', 2); % Draw radius segment on x-axis
% Add a colorbar
caxis([min(z1) max(z1)]);
colorbar;
% Set limits for the plot to improve visibility
xlim([0, max(r)]);
ylim([0, max(r)]);
% Release the figure
hold off; %Zoom out the figure to see the 120 degree sector
Hope this helps!

Categories

Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!