How to plot a circle with polar coordinates in which the colour of the circle changes by data?

조회 수: 3 (최근 30일)
Hi! I want to make something like this, which I found in an article.
In my work I model the drying of granulates, and the moisture content of the particles are changing in the function of time and the radius of the particle. I want to take some timesnaps and plot the moisture content of the particle which is changing with the radius, and next to them the colour bar explains what moisture content belongs to the colour.
So far modelled what I want in a 2D figure, in which I took five different timesnaps, but don't know how to plot like in the upper image.
I attached my code so you have my data. Thank you in advance!
x = linspace(0,0.0008,10);
t = linspace(0,200,50);
m = 0;
eqn = @(x,t,u,dudx) fluidPDE(x,t,u,dudx);
ic = @(x) fluidIC(x);
bc = @(xl,ul,xr,ur,t) fluidBC(xl,ul,xr,ur,t)
sol = pdepe(m,eqn,ic,bc,x,t);
u = sol(:,:,1);
surf(x,t,u)
title('Moisture content')
xlabel('Radius [m]')
ylabel('Time [s]')
zlabel('Moisture content [-]')
figure
hold on
plot(x,u(5,:),'Linewidth',2)
plot(x,u(20,:),'Linewidth',2)
plot(x,u(30,:),'Linewidth',2)
plot(x,u(40,:),'Linewidth',2)
plot(x,u(end,:),'Linewidth',2)
legend('t=5 s','t=20 s','t=30 s','t=40 s','t=50 s')
xlabel('Radius [m]')
ylabel('Moisture content [-]')
title('Moisture content')
function [c,f,s] = fluidPDE(x,t,u,dudx) % Equation to solve
D=3e-9
c = 1/D;
f = dudx;
s = 2/x;
end
% ----------------------------------------------------
function u0 = fluidIC(x) % Initial condition
X0=0.2
u0 = X0;
end
% ----------------------------------------------------
function [pl,ql,pr,qr] = fluidBC(xl,ul,xr,ur,t) % Boundary conditions
D=3e-9
rop=2500
k=1.8e-4
uf=0.05
pl = 0;
ql = 1;
pr = k*(ur-uf);
qr = D;
end

채택된 답변

DGM
DGM 2021년 11월 5일
편집: DGM 2021년 11월 5일
Something like this may suffice. It probably needs quite a bit of tweaking (labels, titles, geometry adjustment) still, but it's a start.
maxradius = 0.0008;
x = linspace(0,maxradius,10);
t = linspace(0,200,50);
m = 0;
eqn = @(x,t,u,dudx) fluidPDE(x,t,u,dudx);
ic = @(x) fluidIC(x);
bc = @(xl,ul,xr,ur,t) fluidBC(xl,ul,xr,ur,t);
sol = pdepe(m,eqn,ic,bc,x,t);
u = sol(:,:,1);
figure(1)
surf(x,t,u)
title('Moisture content')
xlabel('Radius [m]')
ylabel('Time [s]')
zlabel('Moisture content [-]')
figure(2)
hold on
plot(x,u(5,:),'Linewidth',2)
plot(x,u(20,:),'Linewidth',2)
plot(x,u(30,:),'Linewidth',2)
plot(x,u(40,:),'Linewidth',2)
plot(x,u(end,:),'Linewidth',2)
legend('t=5 s','t=20 s','t=30 s','t=40 s','t=50 s')
xlabel('Radius [m]')
ylabel('Moisture content [-]')
title('Moisture content')
% this is the new part
figure(3)
nth = 100;
th = linspace(0,2*pi,nth).';
xx = x.*cos(th);
yy = x.*sin(th);
timeindices = [5 20 30 40];
datarange = [min(u(timeindices,:),[],'all') max(u(timeindices,:),[],'all')];
px = ceil(sqrt(numel(timeindices)));
py = numel(timeindices)/px;
pidx = reshape(1:py*(px+1),px+1,py).';
for k = 1:numel(timeindices)
subplot(py,px+1,pidx(k))
pcolor(xx,yy,repmat(u(timeindices(k),:),[nth 1]));
shading flat
caxis(datarange)
colormap(jet)
axis equal off
ht = text(-1.2*maxradius,-1.2*maxradius, ...
sprintf('time = %d sec',timeindices(k)));
end
ha = subplot(py,px+1,pidx(k+(1:2)));
hp = get(ha,'Position');
caxis(datarange)
colorbar('Position', hp.*[1 1 0.5 0.75] + [hp(3)*0.25 hp(4)*0.125 0 0])
axis off
function [c,f,s] = fluidPDE(x,t,u,dudx) % Equation to solve
D=3e-9;
c = 1/D;
f = dudx;
s = 2/x;
end
% ----------------------------------------------------
function u0 = fluidIC(x) % Initial condition
X0=0.2;
u0 = X0;
end
% ----------------------------------------------------
function [pl,ql,pr,qr] = fluidBC(xl,ul,xr,ur,t) % Boundary conditions
D=3e-9;
rop=2500;
k=1.8e-4;
uf=0.05;
pl = 0;
ql = 1;
pr = k*(ur-uf);
qr = D;
end
  댓글 수: 3
Jani
Jani 2021년 11월 5일
Only not really relevant question remains to me is how to add a subtitle under every circle?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by