Ode45 Error
Contents |
Support Support Newsreader MathWorks Search MathWorks.com MathWorks Newsreader Support MATLAB Newsgroup MATLAB Central Community Home MATLAB Answers File Exchange Cody Blogs Newsreader Link Exchange ThingSpeak Anniversary Home Post A New Message Advanced Search odezero an event disappeared internal error Help MATLAB Central Community Home MATLAB Answers File Exchange Cody Blogs Newsreader Link Exchange matlab ode45 too many input arguments ThingSpeak Anniversary Home Post A New Message Advanced Search Help Trial software ode45 error Subject: ode45 error From: John Hunter error in odearguments at 110 Date: 27 Oct, 2003 11:11:17 Message: 1 of 2 Reply to this message Add author to My Watch List View original format Flag as spam I am integrating a simple 2D linear system with error in ode45 (line 113) a damped oscillation. I was surprised to see that integrating it with ode45 with the default settings causes an error in the result which is noticeable in the plot just after 0.6 seconds as a little blip when the system is at steady state. This is not observed when the system is integrated using a traditional 4th order runge kutta method, eg, http://math.rice.edu/~dfield/other/rk4.m Decreasing the step size
Ode45 Example
did not help get rid of the problem with ode45. The system is characterized by matrix A = [-40 -160; 12.5 -12.5] with a constant input. clear; dt = 0.0005; t = [0:dt:1]; y0 = [0;0]; [tout, yout] = ode45(@derivs, t, y0); %[tout, yout] = rk4('derivs', t(1), t(end), y0, dt); plot(tout, yout) where derivs is function dx = derivs(t,x) d1 = -40*x(1) - 160*x(2) + 80; d2 = 12.5*x(1) -12.5*x(2); dx = [d1; d2]; Comments, suggestions? John Hunter matlab version 6.1.0.450 (R12.1) Subject: ode45 error From: Jacek Kierzenka Date: 27 Oct, 2003 14:14:50 Message: 2 of 2 Reply to this message Add author to My Watch List View original format Flag as spam ODE45 is a variable step implementation, so the code would not change the accuracy as you were changing dt (it would just produce more output points.) Instead, try changing the tolerance(s), for example: options = odeset('RelTol',1e-6); [tout,yout] = ode45(....,options); -Jacek ------------------ John Hunter wrote: > I am integrating a simple 2D linear system with a damped oscillation. > I was surprised to see that integrating it with ode45 with the default > settings causes an error in the result which is noticeable in the plot > just aft
Support Answers MathWorks Search MathWorks.com MathWorks Answers Support MATLAB Answers™ MATLAB Central Community Home MATLAB Answers File Exchange Cody Blogs Newsreader Link Exchange ThingSpeak Anniversary Home Ask Answer Browse More
Ode45 Second Order
Contributors Recent Activity Flagged Content Flagged as Spam Help MATLAB Central Community Home ode45 system of equations MATLAB Answers File Exchange Cody Blogs Newsreader Link Exchange ThingSpeak Anniversary Home Ask Answer Browse More Contributors Recent Activity Flagged ode45 tutorial Content Flagged as Spam Help Trial software Devyani (view profile) 9 questions 0 answers 0 accepted answers Reputation: 0 Vote0 error with using ode45 Asked by Devyani Devyani (view profile) 9 questions 0 https://www.mathworks.com/matlabcentral/newsreader/view_thread/55685 answers 0 accepted answers Reputation: 0 on 17 Oct 2014 Latest activity Commented on by Devyani Devyani (view profile) 9 questions 0 answers 0 accepted answers Reputation: 0 on 18 Oct 2014 82 views (last 30 days) 82 views (last 30 days) i am writing this simple code and it is showing error as below... i dont knw why i am using matlab 2011bfunction dydt https://www.mathworks.com/matlabcentral/answers/159066-error-with-using-ode45 = react(t,y) % Solve the kinetics example dydt = zeros(size(y)); % Parameters k1 = 5; k2 = 2; k3 = 1; A = y(1); B = y(2); C = y(3); dydt(1) =k1*A + k2*B; dydt(2) = k1*A*(k2+k3)*B; dydt(3) = k3*B; error is as followsError using feval Undefined function 'react' for input arguments of type 'double'. Error in odearguments (line 88) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0. Error in ode45 (line 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ... 0 Comments Show all comments Tags ode45 Products No products are associated with this question. Related Content 2 Answers Kelly Kearney (view profile) 12 questions 480 answers 238 accepted answers Reputation: 1,428 Vote0 Link Direct link to this answer: https://www.mathworks.com/matlabcentral/answers/159066#answer_155606 Answer by Kelly Kearney Kelly Kearney (view profile) 12 questions 480 answers 238 accepted answers Reputation: 1,428 on 17 Oct 2014 How are you calling ode45? And where did you save the reac.m function? The error indicates that ode45 isn't seeing the react function it on your path, and therefore can't apply the solver to it. 1 Comment Show all comments Devyani Devyani (view profile) 9 questions 0
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the http://stackoverflow.com/questions/29708940/error-in-using-ode45 workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join error in them; it only takes a minute: Sign up Error in using ode45 up vote 1 down vote favorite I am using pseudo-spectral method to solve a PDE, the transformed ODE is as below: function rhs = vhat(~, vhat0, ~, delta_t,kx) uhat = exp(1i * kx.^3 * delta_t) * vhat0; u = real(ifft(uhat)); u2 = u.^2; g = -0.5 * 1i odezero an event * kx * exp(-1i * kx.^3 * delta_t); rhs = g * fft(real(ifft(u2))); My main code is: %----- Parameters for PDE ----- L = 20; n = 2048; delta_t = 0.001; tmax = 0.5; c1 = 1.5; % amplitude of 1st wave x = linspace(-L/2, L/2, n+1); x = x(1:n); kx = (2*pi/L)*[0:n/2-1 -n/2:-1]; tspan = 0:delta_t:tmax; %-----initial condition z1 = sqrt(c1)/2. * (x-0.1*L); soliton = 6*0.5 * c1 * sech(z1).^2; uhat0 = fft(soliton); vhat0 = uhat0; [t,vhat] = ode45('vhat',tspan, vhat0, [], delta_t,kx); for j=1:length(t) w = real(ifft(vhat(j,:)*exp(1i * kx.^3 * j * delta_t))); plot(x,w) drawnow pause(0.2) end while running this code, I got error as below: Error using * Inner matrix dimensions must agree. Error in vhat (line 6) g = -0.5 * 1i * kx * exp(-1i * kx.^3 * delta_t); Error in odearguments (line 87) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0. Error in ode45 (line 113) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ... Error in kdvm (line 18) [t,vhat] = ode45('vhat',tspan, vhat0, [], delta_t,kx); Anyo
be down. Please try the request again. Your cache administrator is webmaster. Generated Sat, 22 Oct 2016 06:09:13 GMT by s_nt6 (squid/3.5.20)