Error: Creation of Function Handle is not supported by arrayFun call.

I am trying my hand at using GPU tools for ODE computation in efforts to emulate a project that did that. I tried running a simple program through the same. My code is divided into three parts
My Main Function -
tspan = gpuArray([0,20]);
y1=gpuArray(2);
corrected = arrayfun(@wrap,tspan,y1);
[t,y] = gather(corrected);
A wrap function that calls ode45-
function [t,y] = wrap(tspan,y0)
[t,y]= ode45(@vbp1,tspan,y0);
end
vbp1
function dydt = vbp1(t,ya)
dydt = [ya(2); (1-ya(1)^2)*ya(2)-ya(1)];
end
This is the error I seem to be getting
Error using main (line 4)
Creation of function handles is not supported.
For more information see Tips.
Error in 'wrap' (line: 2)
Can anyone figure out why this error is being thrown. I'm fairly new to MATLAB, so please forgive me if the errors are rudimentary.

Answers (1)

You have more than one challenge here.
The one that is more limiting is that ode45 and the similar functions do not support GPUs.
[https://www.mathworks.com/help/matlab/referencelist.html?type=function&capability=gpuarrays>
This is not why you received the error, but it tells you that the other problem is not worth solving at this point.

1 Comment

Thank you so much for the response! I was hoping to emulate this project -
Which seems to have implemented ode45 computations over GPU. If I could trouble you just a bit more to inform me why that project would have worked and not what I have implemented.

Sign in to comment.

Categories

Find more on Parallel Computing Toolbox in Help Center and File Exchange

Asked:

on 19 Oct 2022

Commented:

on 21 Oct 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!