フィルターのクリア

I want to plot two spheres. It appear as ellipses. Can anyone help me?

2 ビュー (過去 30 日間)
Shreen El-Sapa
Shreen El-Sapa 2021 年 11 月 21 日
コメント済み: Star Strider 2021 年 11 月 21 日
a=1;
L=0.1;
dd=5;
c =-a/L;
b =a/L;
m =a*60; %
[x,y]=meshgrid((c+dd:(b-c)/m:b),(c:(b-c)/m:b)');
[I, J]=find(sqrt(x.^2+y.^2)<(a-0.1));
if ~isempty(I)
x(I,J) = 0; y(I,J) = 0;
end
r=sqrt(x.^2+y.^2);
t=atan2(y,x);
r2=sqrt(r.^2+dd.^2-2.*r.*dd.*cos(t));
zet=(r.^2-r2.^2-dd.^2)./(2.*r2.*dd);
warning on
%%%%%%%%%%%%%%%%%%%%
hold on
t3 = linspace(0,2*pi,1000);
h2=0;
k2=0;
rr2=1;
x2 = rr2*cos(t3)+h2;
y2 = rr2*sin(t3)+k2;
set(plot(x2,y2,'-k'),'LineWidth',1.1);
fill(x2,y2,'w')
%axis square;
hold on
t2 = linspace(0,2*pi,1000);
h=dd;
k=0;
rr=2;
x1 = rr*cos(t2)+h;
y1 = rr*sin(t2)+k;
set(plot(x1,y1,'-k'),'LineWidth',1.1);
fill(x1,y1,'w')
%axis square;
axis off

採用された回答

Star Strider
Star Strider 2021 年 11 月 21 日
Adding
axis('equal')
solves it!
a=1;
L=0.1;
dd=5;
c =-a/L;
b =a/L;
m =a*60; %
[x,y]=meshgrid((c+dd:(b-c)/m:b),(c:(b-c)/m:b)');
[I, J]=find(sqrt(x.^2+y.^2)<(a-0.1));
if ~isempty(I)
x(I,J) = 0; y(I,J) = 0;
end
r=sqrt(x.^2+y.^2);
t=atan2(y,x);
r2=sqrt(r.^2+dd.^2-2.*r.*dd.*cos(t));
zet=(r.^2-r2.^2-dd.^2)./(2.*r2.*dd);
warning on
%%%%%%%%%%%%%%%%%%%%
hold on
t3 = linspace(0,2*pi,1000);
h2=0;
k2=0;
rr2=1;
x2 = rr2*cos(t3)+h2;
y2 = rr2*sin(t3)+k2;
set(plot(x2,y2,'-k'),'LineWidth',1.1);
fill(x2,y2,'w')
%axis square;
hold on
t2 = linspace(0,2*pi,1000);
h=dd;
k=0;
rr=2;
x1 = rr*cos(t2)+h;
y1 = rr*sin(t2)+k;
set(plot(x1,y1,'-k'),'LineWidth',1.1);
fill(x1,y1,'w')
%axis square;
axis('equal') % <— ADD THIS LINE HERE
axis off
.
  2 件のコメント
Shreen El-Sapa
Shreen El-Sapa 2021 年 11 月 21 日
Thanks so much
Star Strider
Star Strider 2021 年 11 月 21 日
As always, my pleasure!
.

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

その他の回答 (0 件)

カテゴリ

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