フィルターのクリア

Как вырезать одну поверхность из другой? / How to cut out one surface from another?

4 ビュー (過去 30 日間)
Pavel Kuzmitsky
Pavel Kuzmitsky 2020 年 11 月 17 日
編集済み: Adam Danz 2020 年 11 月 17 日
например у меня есть поверхность круга
[t,r] = meshgrid(linspace(0,2*pi,50),linspace(0,1,50));
[x,y] = pol2cart(t,r);
z=0*x*y;
zcos=cos(z);
surf(x,y,z)
и поверхноть квадрата
[x1,y1] = meshgrid(-2:0.1:2,-2:0.1:2);
z1=0*x1*y1;
surf(x1,y1,z1)
я хочу получить квадрат с дырой внутри от круга
(так же если возможно объясните как получить
поверхность круга в виде нормальной декартовой
сетки, а не в виде полярной)
  1 件のコメント
Adam Danz
Adam Danz 2020 年 11 月 17 日
English translation for future visitors
I have a circle surface, for example
[t, r] = meshgrid (linspace (0.2 * pi, 50), linspace (0.1.50));
[x, y] = pol2cart (t, r);
z = 0 * x * y;
zcos = cos (z);
surf (x, y, z)
and the surface of a square
[x1, y1] = meshgrid (-2: 0.1: 2, -2: 0.1: 2);
z1 = 0 * x1 * y1;
surf (x1, y1, z1)
i want to create a square with a hole inside from the circle
(also, if possible, explain how to get
the surface of a circle as a normal Cartesian
grid, not polar)

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

採用された回答

Adam Danz
Adam Danz 2020 年 11 月 17 日
編集済み: Adam Danz 2020 年 11 月 17 日
Привет Павел
> я хочу получить квадрат с дырой внутри от круга
> i want to create a square with a hole inside from the circle
Since your surfaces are flat and centered on (0,0) you just need to use the radius of the circle to subtract the circle from the square surface.
[x1,y1] = meshgrid(-2:0.1:2,-2:0.1:2);
z1=0*x1*y1;
radius = 2;
circIdx = hypot(x1,y1) < radius;
x1(circIdx) = NaN;
y1(circIdx) = NaN;
figure()
surf(x1,y1,z1)
axis equal
> так же если возможно объясните как получить поверхность круга в виде нормальной декартовой сетки, а не в виде полярной
> also, if possible, explain how to get the surface of a circle as a normal Cartesian grid, not polar
The circular surface in your question is already in Cartesian coordinates. pol2cart converts polar coordinates to Cartesian.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by