Ode45 handles function error
이전 댓글 표시

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
Walter Roberson
2020년 1월 2일
You should be using str2func instead of evalc()
But you have a problem that you have a division by 0. Your first formula crosses 0 slightly above x =-1 and the time is included in all of your timespan for a = -5:-1. This is a problem because you are dividing by that.
esat gulhan
2020년 1월 2일
esat gulhan
2020년 1월 2일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!