在下述代码中,我希望能记录arrayfun函数里面的循环变量z到一个矩阵中,以作进一步的操作。Matlab版本为2017b,代码运行报错为“Array indexing is not supported”。请各位大侠赐教如何才能解决这一问题。
clear all
clc
maxIterations=100;
gridSize=300;
xlim=[-0.75, -0.73];
ylim=[ 0.12, 0.14];
t=tic();
x=gpuArray.linspace(xlim(1), xlim(2), gridSize);
y=gpuArray.linspace(ylim(1), ylim(2), gridSize);
[xGrid,yGrid]=meshgrid(x,y);
Pos=gpuArray.zeros(maxIterations,1);
count=parent_fun(xGrid,yGrid,maxIterations,Pos);
count=gather(count);
gpuArrayfunTime=toc(t)
figure(1)
imagesc(x,y,count)
reset(gpuDevice(1))
%下面是用到的子函数。使用nested function的形式是希望能进行索引,但无效。
function result=parent_fun(xGrid,yGrid,maxIterations,Pos)
function count=tar_fun(x0,y0)
z0=complex(x0,y0);
z=z0;
count=1;
while (count<=maxIterations) && (abs(z)<=2)