# 正不变集（Positive invariant set）的形象理解

5 篇文章 3 订阅

close all; clear; clc;
[xS, yS, zS] = sphere(6);       % 球形数据
sphereRatio = 0.03; xS = sphereRatio*xS; yS = sphereRatio*yS; zS = sphereRatio*zS;
[X,Y,Z] = cylinder([0 sqrt(3)/3], 30);   % 圆锥数据
x_new = 0; y_new = sqrt(3)/3; z_new = 1; idx = 1;
figure(1); set(gcf, 'position', [1920+0 0 1280 600]);
set(gcf, 'Color', 'w');
%% ==============================
subplot(1,2,2); hold on;
contour(X,Y,Z);
title('俯视图'); set(gca, 'FontSize', 16);
xlabel('x'); ylabel('y'); axis equal; grid minor;
handle2DLine = animatedline('Color', 'r', 'LineStyle', '--');
circle(x_new, y_new, sphereRatio, 'b');

subplot(1,2,1); hold on;
mesh(X,Y,Z, 'FaceColor', 'interp', 'FaceAlpha', 0.5, 'EdgeColor', 'k', 'EdgeAlpha', 0, 'LineStyle', '-');
colormap gray;
title('三维视图'); view(-45, 20); set(gca, 'FontSize', 16);
xlabel('x'); ylabel('y'); zlabel('z'); axis equal; grid minor;
handle3DLine = animatedline('Color', 'r', 'LineStyle', '--');
surf(x_new+xS, y_new+yS, z_new+zS, 'FaceColor', 'b','FaceAlpha',0.5,'EdgeColor', 'b', 'EdgeAlpha',1, 'LineStyle', '-');

%% 仿真数据
handleLast = [];
deltaT = 0.05;
vHorizontal = 1; vVertical = 1e-10;

while(z_new > 0)
x = z_new / sqrt(3) * x_new / sqrt(x_new^2 + y_new^2);
y = z_new / sqrt(3) * y_new / sqrt(x_new^2 + y_new^2);
z = z_new;
delete(handleLast);
subplot(1,2,1); handle3D = surf(x+xS, y+yS, z+zS, 'FaceColor', 'r','FaceAlpha',0.5,'EdgeColor', 'r', 'EdgeAlpha',1, 'LineStyle', '-');
handle = legend('$O$', '$x(t, x_0)$', '$x_0$', '$x_{now}$', 'Position', [480 380 0 0]);
set(handle,'Interpreter','latex', 'FontSize', 12);
subplot(1,2,2); handle2D = circle(x, y, sphereRatio, 'r');

%     handle = legend('$O$', '$x(t, x_0)$', '$x_0$');
%     set(handle,'Interpreter','latex', 'FontSize', 12);

handleLast(1) = handle3D; handleLast(2) = handle2D;
x_new =  deltaT * vHorizontal * y / sqrt(x^2 + y^2) + x;
y_new = -deltaT * vHorizontal * x / sqrt(x^2 + y^2) + y;
z_new = -deltaT * vVertical * sqrt(3) / 2 + z;
vVertical = sqrt(vVertical^2 + 2*1*(z - z_new));
im(idx) = getframe(1);            % 获取当前图形
idx = idx + 1;

drawnow;
end

filename = 'simPicture.gif'; % Specify the output file name
for idx = 1:size(im, 2)
[A,map] = rgb2ind(frame2im(im(idx)),256);
if idx == 1
imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',1e-1);
else
imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',1e-1);
end
end

%% ==============================
function handle2D = circle( x,y,r,c )
handle2D = rectangle('Position',[x-r,y-r,2*r,2*r],'Curvature',[1,1],'linewidth',1,...
'FaceColor', c);
end



• 27
点赞
• 32
收藏
觉得还不错? 一键收藏
• 2
评论
12-17 514
02-05 2885
01-10 595
11-20 3596
05-02 1万+
02-20 532
09-25 2333
06-17 2万+

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、付费专栏及课程。