2

My idea here is to represent temperature in a plane circle divided in polar coordinates (grid) using colours, as the plot axis will only show the geometry dimensions.

That's what I have so far.

[R,THETA] = meshgrid(linspace(0,r,nr),linspace(0,theta,ntheta)*(pi/180));
[X,Y] = pol2cart(THETA,R);    
contourf(X,Y,T,10);

enter image description here

The main issues here are that awful line and the absence of the theta grid.

enter image description here

And that's the kind of grid that I'm looking for, but inside of a single plane.

The code:

r = 0.05; % Radius (m)
dr = 0.0025; % Element Size R (m)
nr = r/dr+1; % Number of Elements R
rc = (nr-1)/2+1; % Central Element R

theta = 360; % Degrees (°)
dtheta = 5; % Elezement Size Theta (°)
ntheta = theta/dtheta+1; % Number of Elements Theta

[R,THETA] = meshgrid(linspace(0,r,nr),linspace(0,theta,ntheta)*(pi/180));

[X,Y] = pol2cart(THETA,R);

T1 = 10;
T2 = 50;

dT = T2-T1; % dTemperature

for i = 1:73
    T(i,:) = T1:dT/(nr-1):T2; % Temperatura Distribution
    %T(i,:) = T(i,:) * i*0.5;
end

contourf(X,Y,T,10);

Thank you in advance.

1 Answers1

3

Not sure it's easiest to use mesh here. Why not just plot the lines, similar to what's done in MATLAB's built-in polar():

N_half = 12;
th = (1 : N_half) * 2 * pi / (2 * N_half);
cst = cos(th);
snt = sin(th);
cs = [-cst; cst];
sn = [-snt; snt];
line(r * cs, r * sn, 'Color', 'k');
axis 'square'

gives

enter image description here

where N_half modifies how many lines you are plotting.

lhcgeneva
  • 1,981
  • 2
  • 21
  • 29
  • That solved my problem perfectly! Nice and simple! Do you know the reason for that black line in the right portion of the circle? It keeps showing up! – Vitor Ramalho Nov 26 '15 at 13:40
  • Does it still show up? If I run the last bit of your code and mine immediately afterwards I don't see the black line. – lhcgeneva Nov 26 '15 at 13:44
  • Running the same here and showing up. It must be something related to my settings on this computer, idk. Thank you anyway! Just found another option using "pcolor(X,Y,T);", but I'll keep it simple like this. – Vitor Ramalho Nov 26 '15 at 13:50
  • But if you constrain your axis to a square as done above, you shouldn't see anything black, because it's not within the visible part of the graph, or am I missing something here? Glad I could help anyway! – lhcgeneva Nov 26 '15 at 13:52
  • @VitorRamalho The issue with the unwanted black line [**is adressed here**](http://stackoverflow.com/questions/28239826/removing-the-edge-line-on-a-contour-plot). – Robert Seifert Nov 27 '15 at 07:06
  • Thank you, @thewaywewalk. Very useful. – Vitor Ramalho Nov 27 '15 at 14:48