Surface generation with an external impact at particular point

1 回表示 (過去 30 日間)
Muhammad Mubashar saeed
Muhammad Mubashar saeed 2021 年 5 月 25 日
回答済み: darova 2021 年 5 月 26 日
I want to generate a surface using this code at a particular value of x and y, z will have a specific value otherwise it will be an array of zeros.
[t,r] = meshgrid(0:10:360,0:0.2:5);
[x,y] = pol2cart(t*pi/180,r);
if x=0:1;y=0:1;
z=-90*x.^2*y.^2;
else
z=zeros(size(y));
end
surf(x,y,z)
  2 件のコメント
darova
darova 2021 年 5 月 25 日
Can you make a sketch of a result you expect?
Muhammad Mubashar saeed
Muhammad Mubashar saeed 2021 年 5 月 25 日

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

回答 (1 件)

darova
darova 2021 年 5 月 26 日
See this
[t,r] = meshgrid(0:10:360,0:0.2:5);
[x,y] = pol2cart(t*pi/180,r);
z = -90*x.^2.*y.^2; % remember about dot (.*)
ind = (0<x&x<1) & (0<y&y<1);
z(~ind) = 0; % assign zeros
surf(x,y,z)

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by