The Python Oracle

How to call GEKKO correctly from Matlab

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Music by Eric Matyas
https://www.soundimage.org
Track title: Switch On Looping

--

Chapters
00:00 Question
01:02 Accepted answer (Score 3)
01:39 Thank you

--

Full question
https://stackoverflow.com/questions/5663...

Accepted answer links:
[link]: https://www.mathworks.com/help/matlab/re...
[image]: https://i.stack.imgur.com/vbH8C.png

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #matlab #call #ode #gekko

#avk47



ACCEPTED ANSWER

Score 3


Check this link for how to use pyargs in Matlab. Try using m = py.gekko.GEKKO(pyargs('remote' , 'True'));

m = py.gekko.GEKKO(pyargs('remote' , 'True'));
m.time = py.numpy.linspace(0,20,100);
k = 10;
y = m.Var(5.0);
t = m.Param(m.time);
m.Equation(k*y.dt()==-t*y);
m.options.IMODE = 4;
m.solve(disp==True)

time = cellfun(@double,cell(m.time.tolist()));
y = cellfun(@double,cell(y.VALUE.value));
plot(time,y)
xlabel('Time')
ylabel('y')

enter image description here