Ode45 handles function error

1 次查看(过去 30 天)
esat gulhan
esat gulhan 2020-1-2
My function ug data is got from edittext of GUI
function ut = ug(handles, x, y)
ut = handles.edit11.String
evalc(ut)
vg is like that
Question: When i put the formula to the push button of gui below to get the dy/dx = ug/vg i got error
Formula: for a=-5:1:5;
tspan = [a 6];
y0 = [-5 5];
[xx,yy] = ode45(@(x,y) (vg(handles, x, y))./(ug(handles, x, y)), tspan, y0);
plot(xx,yy,'-k','linewidth',2);
hold on
end
My code works if i create a function like ut=ug(x,y) .... but if i do like that i cant get datas from edittext. How can i activate the code in ode 45 with datas in edit text??
  3 个评论
esat gulhan
esat gulhan 2020-1-2
Well
I change the formula and limits like that.So div/0 is not problem, i erased evalc(ut) in the function and write
function ut = ugs(handles, x, y)
ut = handles.edit11.String
str2func(ut)
end, and rewrite vg too
Formula: for a=1:1:5; (limits changed)
tspan = [a 6];
y0 = [-5 5];
[xx,yy] = ode45(@(x,y) (vg(handles, x, y))./(ug(handles, x, y)), tspan, y0);
plot(xx,yy,'-k','linewidth',2);
hold on
Now it gives new error,
Error using odearguments (line 90)
@(X,Y)UG(HANDLES,X,Y) must return a column vector.
esat gulhan
esat gulhan 2020-1-2
But if i change code like that
[xx,yy] =ode45(@(x,y) (1.5-0.8*y)./(0.8*x+0.5) , tspan, y0)
it works, but my wish to take formulas from the edit text of gui. I dont want to write all time manuel to the formula.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Identification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by