How to generate 3D surface from 2D graph

조회 수: 5 (최근 30일)
Khalid Hasan
Khalid Hasan 2018년 2월 22일
편집: Chunru 2022년 5월 11일
Hi everyone, I am trying to generate a 3D surface from a 2D graph, but haven't succeeded yet. Please help me if there is any possible way to do it. I have attached the code, the equation, corresponding 2D graph, and possible shape which i want to generate. Thank you in advance.
<<
<<
<<
<<
>>
>>
>>
>>
code:
a=0:0.1:2.4
c=sqrt(a.^2+4)
p=23e-7./(c.^6)
plot(a,p)
xlabel('Distance')
ylabel('power')
  댓글 수: 1
Asser Abdelgawad
Asser Abdelgawad 2022년 5월 10일
Try using the cylinder() function, though that only works if you are rotating about the x-axis to generate your 3D surface.

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

답변 (1개)

Chunru
Chunru 2022년 5월 11일
편집: Chunru 2022년 5월 11일
a = (0:0.1:2.4)';
theta = 0:360;
c= sqrt(a.^2+4);
p = 23e-7./(c.^6);
pp = repmat(p', [length(theta) 1]);
[aa, tt] = meshgrid(a, theta);
xx = aa.*cosd(tt);
yy = aa.*sind(tt);
figure
plot(a,p)
xlabel('Distance')
ylabel('power')
% whos
figure
surf(xx, yy, pp, 'EdgeColor', 'none')
% Alternatively
a = (-2.4:0.1:2.4)';
x = a; y = a;
[xx, yy] = meshgrid(x, y);
pp = 23e-7./(xx.^2+yy.^2+4).^3;
figure
surf(xx, yy, pp, 'EdgeColor', 'none')

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by