Make a 3D plot over a circle
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Bob Schreurs
el 26 de En. de 2022
Comentada: Benjamin Kraus
el 26 de En. de 2022
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 comentarios
Respuesta aceptada
Benjamin Kraus
el 26 de En. de 2022
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 comentarios
Benjamin Kraus
el 26 de En. de 2022
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)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!