plot3 with implicit domain

3 ビュー (過去 30 日間)
Niklas Kurz
Niklas Kurz 2021 年 4 月 27 日
編集済み: Niklas Kurz 2021 年 5 月 2 日
I'd like to plot f(u,v) = (u,v,sqrt(1-u^2-v^2)) whereas u^2+v^2 <1;
I thought of using plot3 and defining
[u,v] = deal(linspace(-2,2,200));
Thing is, I got to incorporate the implicit condition somehow. Fimplicit3 doesn't help here. I could probalby solve for one of the variables and substitute but that's getting already complex in my head. Is there a handy solution?

採用された回答

DGM
DGM 2021 年 4 月 27 日
Maybe something like this?
n = 50;
u = linspace(-2,2,n);
v = linspace(-2,2,n)';
f = u.^2 - v.^2; % the function
dm = (u.^2 + v.^2)<1; % the domain mask
f(~dm) = NaN; % NaN values don't plot
mesh(u,v,f)
axis equal
colormap(1-ccmap)
title('Math Pringle')
  5 件のコメント
DGM
DGM 2021 年 4 月 28 日
編集済み: DGM 2021 年 4 月 28 日
It's easier to understand once you realize what the results from meshgrid look like. Two orthogonal vectors contain the same information that two 2D grids do. The grids are just replicated vectors.
Another way to think of it is to consider what happens when the vectors aren't orthogonal:
x = linspace(-1,1,10);
y = linspace(-1,1,10);
z1 = x.^2 + y.^2; % this is a vector
z2 = x.^2 + y'.^2; % this is a 2D array (due to implicit array expansion)
These two results are related, but it all depends what the goal is. Both z1 and z2 describe a paraboloid. z2 describes the paraboloid over the entire rectangular domain from [-1,-1] to [1,1]. z1 only describes the paraboloid on the diagonal line between said points. One is a surface, where the other is only a curve on said surface.
Niklas Kurz
Niklas Kurz 2021 年 4 月 29 日
編集済み: Niklas Kurz 2021 年 5 月 2 日
that illustration was beautiful

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by