Graphing in Cylindrical Coordinates using MATLAB

Hello,
I want to reproduce this graph... http://i45.tinypic.com/121xra1.jpg ... using MATLAB.
It's the graph of g(r, theta) = 1 + r^2*sin(theta) over the unit circle.
Does anyone have any advice?
Thanks :)

 채택된 답변

Geoff
Geoff 2012년 4월 30일

0 개 추천

Advice is to make a start and show us what you have done so far.
Here is my primer:
r = 0:0.1:1;
theta = linspace(0, 2*pi, 12);
You need to use meshgrid
doc meshgrid
And surf
doc surf
And a polar co-ordinate conversion
<insert high-school trigonometry>
The colour map is jet.
I think that's plenty to get you started =)

댓글 수: 6

Mark
Mark 2012년 5월 3일
Thanks for your response Geoff.
How does this look...?
r=0:0.1:1;
theta=linspace(0, 2*pi, 12);
[r,theta]=meshgrid(r,theta);
x=r.*cos(theta);
y=r.*sin(theta);
z=1+r.^2.*sin(theta);
mesh(x,y,z)
grid on
box on
axis tight
view([130,30])
xlabel('x = r cos(theta)')
ylabel('y = r sin(theta)')
zlabel('g(r,theta)')
title('Questions 6(b)')
Cheers
Geoff
Geoff 2012년 5월 3일
Well, I presume that you are supposed to generate something that looks EXACTLY like the example?
In that case you have some work to do yet.
Use '\theta' to get the right symbol.
You need to set your axis ticks up correctly, and make the guides the right colour.
I notice I was wrong about the 12 divisions (because it wraps around to zero again). You need 13 divisions.
You also need to set up the camera in the correct place.
The title is "Question" not "Questions".
Attention to detail!!
Geoff
Geoff 2012년 5월 3일
Oh, and I don't think the example picture uses 'box on', do you?
Geoff
Geoff 2012년 5월 3일
And one last hint on camera placement. Look at the line on the mesh that appears to be vertical. You want your camera rotated to that point, and you need to experiment with the tilt to get the right elevation. Standard isometric view used by engineers. It'll be an obvious angle.
Mark
Mark 2012년 5월 3일
Thanks again for your comments.
I've got it to this:
r=0:0.1:1;
theta=linspace(0, 2*pi, 13);
[r,theta]=meshgrid(r,theta);
x=r.*cos(theta);
y=r.*sin(theta);
z=1+r.^2.*sin(theta);
mesh(x,y,z)
grid on
axis tight
view([300,30])
xlabel('x = r cos(\theta)')
ylabel('y = r sin(\theta)')
zlabel('g(r,\theta)')
title('Question 6(b)')
the only thing I can see that needs changing the the scaling on the axes
Geoff
Geoff 2012년 5월 3일
Really?
I can see:
- Axis tick labels (and number of grid guides) not consistent with example;
- Colour of grid guides not consistent with example;
- Aspect ratio of default figure not consistent with example;
- Anti-aliasing of mesh lines not consistent with example;
- Background colour of figure not consistent with example.
I pointed out some of these things before. Aren't you lucky to stumble across a fussy old bugger like myself to make your life difficult =)

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Polar Plots에 대해 자세히 알아보기

질문:

2012년 4월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by