plot simple 2D-surface from 2D-vector valued function

25 ビュー (過去 30 日間)
Niklas Kurz
Niklas Kurz 2021 年 5 月 2 日
回答済み: Adam Danz 2021 年 5 月 3 日
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 件のコメント
Niklas Kurz
Niklas Kurz 2021 年 5 月 2 日
編集済み: Niklas Kurz 2021 年 5 月 2 日
z = zeros(size(u))
would fullfill the purpose, but the object still is living in 3D
Niklas Kurz
Niklas Kurz 2021 年 5 月 2 日
What also seems to work:
u = linspace(0,1); v = linspace(0,2*pi)
v = v';
x = u.*sin(v); y = u.*cos(v);
plot(x,y)
But also not right what I'm striving for because points are connected as line.

サインインしてコメントする。

採用された回答

Scott MacKenzie
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.

その他の回答 (1 件)

Adam Danz
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')

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by