
3D surface issues HELP!
조회 수: 1 (최근 30일)
이전 댓글 표시
- * So these are the questions... most of the variables are fixed the long equation has been dramatically simplified in my code :) * *

- | This is what mine looks like.. |

What it should look like...

This is my code...
% Q = theta
r = linspace(0,15,200);
Q = linspace(0,2*pi,200);
[r,Q] = meshgrid(r,Q);
w = 14.0591*(1-(r/15)^2)^2 + 15;
x = r.*cos(Q);
y = r.*sin(Q);
mesh(x,y,w)
What have I done wrong? Why isnt mine round, I dont think 'r' is being inputed into the 'w' equation correctly, HELP!
댓글 수: 0
채택된 답변
Star Strider
2014년 10월 7일
You need to vectorise your code and it will do just what you want:
r = linspace(0,15);
Q = linspace(0,2*pi);
[r,Q] = meshgrid(r,Q);
w = 14.0591*(1-(r/15).^2).^2 + 15;
x = r.*cos(Q);
y = r.*sin(Q);
mesh(x,y,w)

댓글 수: 9
Star Strider
2014년 10월 7일
편집: Star Strider
2014년 10월 7일
My pleasure!
The sincerest expression of gratitude here on MATLAB Answers is to Accept the answer that most closely solves your problem.
추가 답변 (1개)
Image Analyst
2014년 10월 7일
r is an array so you need .^ and not just ^. Try this:
workspace;
r = linspace(0,15,200);
Q = linspace(0,2*pi,200);
[r,Q] = meshgrid(r,Q);
w = 14.0591*(1-(r/15).^2).^2 + 15;
x = r.*cos(Q);
y = r.*sin(Q);
mesh(x,y,w)
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
