From: trung trinh on 18 Apr 2010 12:49 function vdp syms t; f = sin(t)*cos(t)*exp(-100*t); % This is an example function. Our function maybe more complex than it. tspam = [0 12]; x0 = [0 1]'; [t, x] = ode45(@vdpp, tspam, x0, [], f); plot(t,x(:, 1)); grid on; function dxdt = vdpp(t, x,f) dxdt = [x(1); x(2)+f]; Dont work. Help me
From: Torsten Hennig on 18 Apr 2010 22:40 > tspan = [0 12]; > x0 = [0 1]'; > [t, x] = ode45(@vdpp, tspan, x0, []); > plot(t,x(:, 1)); grid on; > function dxdt = vdpp(t, x) > dxdt = [x(1); x(2)+sin(t)*cos(t)*exp(-100*t)]; > Best wishes Torsten.
From: Steven Lord on 19 Apr 2010 11:43 "trung trinh" <trungkstn(a)gmail.com> wrote in message news:hqfd60$o0k$1(a)fred.mathworks.com... > function vdp > syms t; > f = sin(t)*cos(t)*exp(-100*t); % This is an example function. Our > function maybe more complex than it. > tspam = [0 12]; > x0 = [0 1]'; > [t, x] = ode45(@vdpp, tspam, x0, [], f); > plot(t,x(:, 1)); grid on; > function dxdt = vdpp(t, x,f) > dxdt = [x(1); x(2)+f]; > > Dont work. Help me DO NOT mix ODE45 and symbolic expressions; if you want to solve a system symbolically use DSOLVE, if you want to solve it numerically use ODE45 (or use SUBS to evaluate the symbolic expression to return a numeric result.) -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ.
|
Pages: 1 Prev: Adding arrows to axes Next: Inverse of Function in Matlab |