3-масала.
ошкор берилган функцияни ОХ ўқи атрофида
айланишдан ҳосил бўладиган сиртни ясанг.
Дастур:
x1=0; x2=2; a=1;
u=x1:0.1:x2;
v=0:pi/20:2*pi;
[U,V]=meshgrid(u,v);
F=a*(exp(-U/a)+exp(U/a))/2;
X=U; Y=F.*cos(V); Z=F.*sin(V);
figure; hFigure=gcf;
set(hFigure,'Color',[0.9 0.8 0.8]);
surf(X,Y,Z)
colorbar;
view([-75,20])
hold on
x=0:0.1:x0; y=a*(exp(-x/a)+exp(x/a))/2;
hPlot=plot(x,y); set(hPlot,'LineWidth',5)
Натижа:
290
9.2.3-расм. Функцияни ОХ ўқи атрофида айланишдан ҳосил бўлган сирт.
4 - масала.Астроидани айланишидан ҳосил бўлган сиртни визуаллаш-
тиринг.
Дастур:
Астроидани ясаш
a=2;
t=-2*pi:pi/20:2*pi;
X=a*cos(t).^3;
Y=a*sin(t).^3;
w=300;
h=300; figure('Units','Pixels','position',
[100,100,w,h]);
plot(X,Y)
xlabel('x'); ylabel('y');
axis([-3, 3, -3, 3]);
Натижа:
9.2.4-расм. Астроида чизмаси.
% Айланиш сирти
a=2;
t=-2*pi:pi/20:2*pi;
X=a*cos(t).^3;
v=0:pi/20:2*pi;
[T,V]=meshgrid(t,v);
Y=a*sin(T).^3;
X1=X;
Y1=Y.*cos(V);
Z1=Y.*sin(V);
figure;
hFigure=gcf;
set(hFigure,'Color',[1 1 1]);
surf(X1,Y1,Z1)
hAxes=gca;
291
set(hAxes,'Color',[0.9,0.9,0.9]);
colorbar;
xlabel('x'); ylabel('y'); zlabel('z');
view([-24,40])
hold on
hPlot=plot(X,Y);
set(hPlot,'LineWidth',5)
set(hPlot,'Color',[1 0 1])
Натижа:
9.2.5-расм. АстроиданингОХ ўқи атрофида айланишидан ҳосил бўлган
сирт.
5-масала.Қутб координатадларда Бернулли лимнискатасини ясанг:
Дастур:
a=1;
r=[]; phi=[];
for p=0:pi/60:2*pi
if 2*a^2*cos(2*p)>=0
r=[r sqrt(2*a^2*cos(2*p))];
phi=[phi p];
end
end
hFigure=gcf;
set(hFigure,'Color',[1 1 1]);
hP=polar(phi,r);
set(hP,'LineWidth',2);
Натижа:
9.2.6.-расм.Бернулли лимнискатаси.
|