How can I plot just a slice of circle that shows the degree of temperature

2 views (last 30 days)
Hello,
I am using MatLab to study heat transfer and now I am developing a method for cylindrical coordinates. This is my code:
clear
clc
theta = linspace(-pi/8,pi/8,7);
r = linspace(0,1,10);
[AA,RR] = meshgrid(theta,r);
polar(AA,RR,'or');
How you can see, it's easy to understand what does it means. I made a grid to use FEM to solve.
When I run this cole the graphic shows:
There is nothing wrong with the image but I would like something look like it:
Probably it will be necessary to use other structure to plot the graphic, and not polar. Do you know what option do I have?
Cheers

Accepted Answer

Star Strider
Star Strider on 30 Sep 2017
I would use the pol2cart funciton:
theta = linspace(-pi/8,pi/8,7);
r = linspace(0,1,10);
[AA,RR] = meshgrid(theta,r);
[X,Y] = pol2cart(AA,RR);
figure(1)
plot(X,Y, 'or')
axis([-1.1 1.1 -1.1 1.1])
axis equal
Experiment with the axis function calls to get the plot appearance you want.
  2 Comments
yogan sganzerla
yogan sganzerla on 30 Sep 2017
Hi,
It worked very well. How could you see, I have 70 points and in each point, I will calculate the temperature at each point and time. In other words, I will have T(Theta,r,t) where t is the time.
The result that I would like to achieve is something like it.
When I was plotting with rectangular coordinates, I used pcolor(T(:,:,t)) and now with cylindrical coordinates? for example, in time 1, my multidimensional matrix is T(:,:,1)= 300 ºC and all the mesh grid should be red.
What should I do to plot it?
cheers
Star Strider
Star Strider on 30 Sep 2017
I have no idea how you calculate ‘Z’, so I created an expression for it to illustrate the correct approach:
theta = linspace(-pi/8,pi/8,7);
r = linspace(0,1,10);
[AA,RR] = meshgrid(theta,r);
[X,Y] = pol2cart(AA,RR);
Z = 1./(RR); % Create ‘Z’
figure(2)
surf(X, Y, Z)
colormap(jet(length(r)));
view([0 90])
axis equal
This actually gives something similar to the figure you illustrate.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!