Undefined function or variable
Afficher commentaires plus anciens
Hello,
I'm trying to improve my code execution speed by using GPU, here is my code :
.
......
size_mat=size(ind_mat,1);
tryy=gpuArray(tryy);
ind_mat=gpuArray(ind_mat);
tryy=arrayfun(@aGpuFunction, tryy, ind_mat,size_mat);
sinogram = tryy;
sinogram = gather(sinogram);
.......
And the function:
.
function tryy = aGpuFunction(tryy,ind_mat,size_mat)
for k=1:size_mat
if( ind_mat(k,2)~=1&&ind_mat(k,3)~=4008&&ind_mat(k,1)~=1&&ind_mat(k,1)~=4500)
tryy(ind_mat(k,1),ind_mat(k,2))=(tryy(ind_mat(k,1)-1,ind_mat(k,2))+tryy(ind_mat(k,1)+1,ind_mat(k,2))+tryy(ind_mat(k,1),ind_mat(k,2)-1))./3;
tryy(ind_mat(k,1),ind_mat(k,3))=(tryy(ind_mat(k,1)-1,ind_mat(k,3))+tryy(ind_mat(k,1)+1,ind_mat(k,3))+tryy(ind_mat(k,1),ind_mat(k,3)+1))./3;
end
end
When I execute my code, i got the following error :
Error using parallel.gpu.GPUArray/arrayfun
Undefined function or variable 'k'.
Error in antispeckle_filter (line 22)
tryy=arrayfun(@aGpuFunction, tryy, ind_mat,size_mat);
I'm stuck here... Does anyone got an idee ?
Thanks!
Selim
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur GPU Computing in MATLAB dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!