我有大量的 for 循环;有什么办法可以让这个运行得更快吗?获取散点图需要 30 多分钟。
我在想也许可以使用休息。是否有可能或者我需要使用其他东西来让程序逐段运行?
A = [4/5 -1/5 -1/5 -1/5 -1/5; -1/5 4/5 -1/5 -1/5 -1/5; -1/5 -1/5 4/5 -1/5 -1/5;-1/5 -1/5 -1/5 4/5 -1/5; -1/5 -1/5 -1/5 -1/5 4/5];
B = [ 0 0 0 0 0 ; 0 0 0 0 1 ; 0 0 0 1 0 ; 0 0 0 1 1 ; 0 0 1 0 0 ; 0 0 1 0 1 ];
for i = 1:size(B,1)
p1 = A * B(1,:)' -A * B(i,:)';
dtransformation0a(i) = d*p1;
qtransformation0a(i) = q*p1;
for i = 1:size(B,1)
p2 = A * B(2,:)' -A * B(i,:)';
dtransformation0b(i) = d*p2;
qtransformation0b(i) = q*p2;
for i = 1:size(B,1)
p3 = A * B(3,:)' -A * B(i,:)';
dtransformation0c(i) = d*p3;
qtransformation0c(i) = q*p3;
for i = 1:size(B,1)
p4 = A * B(4,:)' -A * B(i,:)';
dtransformation0d(i) = d*p4;
qtransformation0d(i) = q*p4;
for i = 1:size(B,1)
p5 = A * B(5,:)' -A * B(i,:)';
dtransformation0e(i) = d*p5;
qtransformation0e(i) = q*p5;
for i = 1:size(B,1)
p6 = A * B(6,:)' -A * B(i,:)';
dtransformation0f(i) = d*p6;
qtransformation0f(i) = q*p6;
end
end
end
end
end
end
figure
scatter(dtransformation0a,qtransformation0a,100,'b.')
%text(dtransformation0a(:), qtransformation0a(:), labels, 'VerticalAlignment','bottom', ...
% 'HorizontalAlignment','right')
hold on
scatter(dtransformation0b,qtransformation0b,100,'b.')
%text(dtransformation0a(:), qtransformation0a(:), labels, 'VerticalAlignment','bottom', ...
% 'HorizontalAlignment','right')
hold on
scatter(dtransformation0c,qtransformation0c,100,'b.')
%text(dtransformation0a(:), qtransformation0a(:), labels, 'VerticalAlignment','bottom', ...
% 'HorizontalAlignment','right')
hold on
scatter(dtransformation0d,qtransformation0d,100,'b.')
%text(dtransformation0a(:), qtransformation0a(:), labels, 'VerticalAlignment','bottom', ...
% 'HorizontalAlignment','right')
hold on
scatter(dtransformation0e,qtransformation0e,100,'b.')
%text(dtransformation0a(:), qtransformation0a(:), labels, 'VerticalAlignment','bottom', ...
% 'HorizontalAlignment','right')
hold on