0
我想计算不在圆圈内的外部点数。但我有这个问题。我的圈子是单位圈。我的错误是:外部临时变量将在parfor循环的每个迭代 开始时被清除。使用带有临时变量的parfor
function [ ] = girkoson(N,n)
%UNTİTLED Summary of this function goes here
% Detailed explanation goes here
hold on
outside = 0;
parfor i=0:N
E=ones(N,n);
karekok = sqrt(n);
E = [E, eig(randn(n))/karekok];
a=real(E);
b= imag(E);
plot(a,b,'.r');
if (a>= -1) | (a<=1) | (b>=-1) | (b<=1)
outside = outside +1;
fprintf('%f',outside);
end
end
derece=0:0.01:2*pi;
xp=1*cos(derece);
yp=1*sin(derece);
x=0;y=0;
plot(x+xp,y+yp,'-b');
hold off
end
什么问题?你只是在这里丢弃你的代码。你的问题是什么? – Adriaan
我刚刚编辑 – Bertug