4

I found a function for calling python from Matlab. So, I tried to use this function for calling GEKKO package from Matlab for solving ODE. I have gotten an error for defining a gekko option (remote=true) as function or variable.

I opened Matlab with Anaconda Prompt.

m = py.gekko.GEKKO(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')

error message Undefined function or variable 'remote'.

Error in ODE_gekko_matlab (line 5) m = py.gekko.GEKKO(remote==True); % Solve on local machine

Junho Park
  • 997
  • 4
  • 12

1 Answers1

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

reyPanda
  • 510
  • 2
  • 11
  • 2
    I just tested in Matlab and ```'True'``` (uppercase) or ```'true'``` (lowercase) work the same. This is interesting because in Python, ```'true'``` (lowercase) will return an error. – reyPanda Jun 17 '19 at 23:08