plot simple 2D-surface from 2D-vector valued function
8 次查看(过去 30 天)
显示 更早的评论
It's really frustrating me that I manage to transfer it into 3D and not 2D. Her'es what I'm talking about:
I got a function f: (u,v) ->(u*sin(v),u*cos(v),u^2) where u in (0,1) and v in (0,2*pi)
What's working flawlessly:
[u,v] = meshgrid(linspace(0,1),linspace(0,2*pi));
x = u.*sin(v); y = u.*cos(v); z = u.^2;
mesh(x,y,z)
But what IF I just want to plot x and y without z? According to my imagination a filled circle should be the outcome.
mesh(x,y)
is not supporting that point of view
2 个评论
采纳的回答
Scott MacKenzie
2021-5-2
编辑:Scott MacKenzie
2021-5-3
Seems you just want the points and not the lines connecting the points. In that case, just add a line specifier to plot to specify plotting just the points:
u = linspace(0,1); v = linspace(0,2*pi)
v = v';
x = u.*sin(v); y = u.*cos(v);
plot(x,y,'.'); % '.' is a line specifier -- just the points are plotted
Here's the output, zoomed in a bit to show that only the points are plotted:
Having just re-read your original question, perhaps you want a "filled circle". In that case, use patch instead of plot:
u = linspace(1, 0); % NOTE: largest circle first
v = linspace(0, 2*pi);
v = v';
x = u.*sin(v);
y = u.*cos(v);
c = 1:100;
patch(x, y, c, 'edgecolor', 'none');
The circle edges are turned off to prevent the lines from dominating the visual result. Note as well that the circle patches are created largest to smallest. This is needed so new circles are visible on top of previous circles.
0 个评论
更多回答(1 个)
Adam Danz
2021-5-3
Perhaps you're just looking for a top-down view of the 3D axes
[u,v] = meshgrid(linspace(0,1),linspace(0,2*pi));
x = u.*sin(v); y = u.*cos(v); z = u.^2;
mesh(x,y,z)
view(2) % <---- set view
xlabel('x axis')
ylabel('y axis')
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!