Plotting 3D graph in polar coordinates
조회 수: 8 (최근 30일)
이전 댓글 표시
I'm trying to plot a 3D graph of a function in polar coordinates. The function takes a different form at different values of r. a, b and multiplier are constants I've defined earlier in the code (a=11, b=60, multiplier =-14)
r=0:1:60;
theta=0:pi/30:2*pi;
for i=1:61
r(i)=i-1;
if (r(i)<a)
sigmar(i)=-p_i;
else
sigmar(i)=((1-((b^2)/(r(i)^2)))*multiplier);
end
end
I've been trying to plot the 3D curve using
[x,y]=pol2cart(theta, r);
surf(x,y,sigmar)
but when I run the code, it keeps saying 'Data dimensions must agree.'
댓글 수: 2
채택된 답변
madhan ravi
2018년 11월 11일
편집: madhan ravi
2018년 11월 11일
clear all
r=0:1:60;
theta=0:pi/30:2*pi;
for i=1:61
r(i)=i-1;
if (r(i)<3)
sigmar(i)=-6;
else
sigmar(i)=((1-((7^2)/(r(i)^2)))*-14); %multiplier is a predefined constant
end
end
[x,y]=pol2cart(theta, r);
[X,Y]=meshgrid(x,y);
sigmar=repmat(sigmar,61,1);
surf(X,Y,sigmar)
댓글 수: 5
추가 답변 (0개)
참고 항목
카테고리
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!