我现在无法访问 MATLAB 解释器,所以我无法自己测试它,但这应该可以:
A = [2/3 -1/3 -1/3;
-1/3 2/3 -1/3;
-1/3 -1/3 2/3];
B = [0 0 0;
0 0 1;
0 1 0;
0 1 1;
1 0 0;
1 0 1;
1 1 0;
1 1 1];
d = [2/3 -1/3 -1/3];
q = [0 0.5773 -0.5773];
for i = 1:size(B,1)
p1 = A * B(1,:)' -A * B(i,:)';
dtransformation0a(i) = d*p1;
qtransformation0a(i) = q*p1;
p2 = A * B(2,:)' -A * B(i,:)'
dtransformation0b(i) = d*p2;
qtransformation0b(i) = q*p2;
p3 = A * B(3,:)' -A * B(i,:)';
dtransformation0c(i) = d*p3;
qtransformation0c(i) = q*p3;
p4 = A * B(4,:)' -A * B(i,:)';
dtransformation0d(i) = d*p4;
qtransformation0d(i) = q*p4;
p5 = A * B(5,:)' -A * B(i,:)';
dtransformation0e(i) = d*p5;
qtransformation0e(i) = q*p5;
p6 = A * B(6,:)' -A * B(i,:)';
dtransformation0f(i) = d*p6;
qtransformation0f(i) = q*p6;
end
X = [dtransformation0a, dtransformation0b]; %Assuming dtransformation0a and dtransformation0b are row martices.
Y = [qtransformation0a, qtransformation0b]; %Assuming qtransformation0a and qtransformation0b are row martices.
my_points = [X';Y']; %Each row of my_points will represent a particular point.
my_points = unique(my_points, 'rows'); %Get unique rows, hence points.
figure
scatter(my_points(:,1),my_points(:,2),100,'b.')
如果您遇到任何问题,请告诉我。
**
编辑!!
**
根据您的要求,我的理解是您想要显示那些产生值的计算,例如(0,0)
,如果这确实是您想要的,您应该能够通过将循环部分替换为:
my_point = [0, 0];
for i = 1:size(B,1)
p1 = A * B(1,:)' -A * B(i,:)';
dtransformation0a(i) = d*p1;
qtransformation0a(i) = q*p1;
p2 = A * B(2,:)' -A * B(i,:)'
dtransformation0b(i) = d*p2;
qtransformation0b(i) = q*p2;
p3 = A * B(3,:)' -A * B(i,:)';
dtransformation0c(i) = d*p3;
qtransformation0c(i) = q*p3;
p4 = A * B(4,:)' -A * B(i,:)';
dtransformation0d(i) = d*p4;
qtransformation0d(i) = q*p4;
p5 = A * B(5,:)' -A * B(i,:)';
dtransformation0e(i) = d*p5;
qtransformation0e(i) = q*p5;
p6 = A * B(6,:)' -A * B(i,:)';
dtransformation0f(i) = d*p6;
qtransformation0f(i) = q*p6;
if(dtransformation0a(i)==my_point(1))
fprintf("dtransformation0a => (%f = %f * %f;)\n",dtransformation0a(i),d,p1);
end
if(dtransformation0b(i)==my_point(1))
fprintf("dtransformation0b => (%f = %f * %f;)\n",dtransformation0b(i),d,p2);
end
if(qtransformation0a(i)==my_point(2))
fprintf("qtransformation0a => (%f = %f * %f;)\n",qtransformation0a(i),q,p1);
end
if(qtransformation0b(i)==my_point(2))
fprintf("qtransformation0b => (%f = %f * %f;)\n",qtransformation0b(i),q,p2);
end
end
我希望这就是你要找的。