Make a 3D plot over a circle

조회 수: 17 (최근 30일)
Bob Schreurs
Bob Schreurs 2022년 1월 26일
댓글: Benjamin Kraus 2022년 1월 26일
Hello everyone,
I am currently researching the characteristic of a fan. Therefore I am measuring the wind speed on 9 different points as can be seen in the attachment: 'Ventilator en meetpunten'.
I plotted the velocity at every point I measured it in a 2D plot as can be seen in the attachment: ''
The velocity values plotted on the y-axis are: 0, 0.854, 1.686, 6.7075, 8.52, 10.15, 10.4775, 9.825, 9.65, 0.
Is it possible to plot this 2D graph over a cirle (2*PI) in MatLab, so it becomes a 3D plot? If yes, I would like some help with it.
Thank you in advance.
With kind regards,
Bob Schreurs
  댓글 수: 2
Rik
Rik 2022년 1월 26일
So you want to plot something similar to surf?
Bob Schreurs
Bob Schreurs 2022년 1월 26일
Exactly, but with the circle as base plane and the 2D plot over the circle, so it becomes 3D (if you understand what I mean).

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

채택된 답변

Benjamin Kraus
Benjamin Kraus 2022년 1월 26일
There are tons of options for doing this in MATLAB. Here are a few:
% First define some constants and your input data (as I understand it from
% the picture).
centerRadius = 150/2;
outerRadius = 730/2;
windSpeed = [0, 0.854, 1.686, 6.7075, 8.52, 10.15, 10.4775, 9.825, 9.65, 0];
theta = zeros(size(windSpeed));
r = linspace(centerRadius, outerRadius, numel(windSpeed));
The first option is to use the rectangle command to draw circles and scatter3 to draw dots at each reading. These circles will be drawn at Z = 0.
figure
x = r.*cos(theta);
y = r.*sin(theta);
scatter3(x, y, windSpeed, 'filled')
rectangle('Position',outerRadius*[-1 -1 2 2], 'Curvature', [1 1])
rectangle('Position',centerRadius*[-1 -1 2 2], 'Curvature', [1 1])
If you want to draw those "rectangles" at something other than Z = 0, then you can use an hgtransform.
figure
x = r.*cos(theta);
y = r.*sin(theta);
scatter3(x, y, windSpeed, 'filled')
t = hgtransform;
rectangle('Parent',t,'Position',outerRadius*[-1 -1 2 2], 'Curvature', [1 1])
rectangle('Parent',t,'Position',centerRadius*[-1 -1 2 2], 'Curvature', [1 1])
t.Matrix = makehgtform('translate', [0 0 5]);
More likely you want to draw some kind of 3D cylinder, and you can do that using a combination of cylinder and surface.
figure
x = r.*cos(theta);
y = r.*sin(theta);
scatter3(x, y, windSpeed, 'filled')
[x, y, z] = cylinder(outerRadius, 101);
surface(x,y,z*max(windSpeed),'FaceAlpha',0.1,'EdgeColor','none');
[x, y, z] = cylinder(centerRadius, 101);
surface(x,y,z*max(windSpeed),'FaceAlpha',0.1,'EdgeColor','none');
Do any of these pictures look like what you are trying to do?
  댓글 수: 5
Bob Schreurs
Bob Schreurs 2022년 1월 26일
This is exactly what I mean, thanks a lot!
Benjamin Kraus
Benjamin Kraus 2022년 1월 26일
For example, I tweaked some more settings and overlayed two surfaces to get fewer edge lines but keep the smooth curve:
centerRadius = 150/2;
outerRadius = 730/2;
windSpeed = [0, 0.854, 1.686, 6.7075, 8.52, 10.15, 10.4775, 9.825, 9.65, 0];
theta = zeros(size(windSpeed));
r = linspace(centerRadius, outerRadius, numel(windSpeed));
[x, y, z] = cylinder(r, 361);
z = z.*windSpeed'; % Note the use of implicit scalar expansion
s = surf(x,y,z,'FaceAlpha', 0.4,'MeshStyle','row');
s.FaceColor = lines(1);
[x, y, z] = cylinder(r, 8);
z = z.*windSpeed';
surface(x,y,z,'FaceColor','none','MeshStyle','column')
view(-45, 70)

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

추가 답변 (1개)

Torsten
Torsten 2022년 1월 26일
편집: Torsten 2022년 1월 26일
r=linspace(75,365,25);
phi=linspace(0,2*pi,36);
[R,PHI]=meshgrid(r,phi);
X=R.*cos(PHI);
Y=R.*sin(PHI);
Z=interp1(rm,velm,sqrt(X.^2+Y.^2));
surf(X,Y,Z)
where rm and velm are radius and velocity of your measurements.
  댓글 수: 1
Bob Schreurs
Bob Schreurs 2022년 1월 26일
Thank you for your reaction, I managed to do it.

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by