Hi. We are working on a slighty larger system in Matlab than we're used to (we are simulating interacting particles). We want to solve our differential equations for the motion of particles with matlabs ode15s. But we get the error:
??? Error using ==> fevalUndefined function or method 'Compute_ODEfunction' for input arguments of type 'double'.Error in ==> odearguments at 110f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode15s at 228[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...Error in ==> particle_system>particle_system.advance_time at 79 [~,X] = ode15s(...Error in ==> Partikelsimulering at 64 Particle_System.advance_time (step_time);
Our code is:
function advance_time (Particle_System, step_time) Particle_System.kill_old_particles; time_start = Particle_System.time; time_end = time_start + step_time; tspan = [time_start, time_end]; phase_space_state = Particle_System.get_phase_space_state'; [~,X] = ode15s(... @Compute_ODEfunction, ... tspan, ... phase_space_state); for i = 1:6*length(Particle_System.particles) phase_space_state(i) = X(end,i); end Particle_System.set_phase_space_state (phase_space_state); Particle_System.time = time_end; title(Particle_System.time); Particle_System.advance_particles_ages (step_time); Particle_System.update_graphics_positions; end
And @Compute_ODEfunction (it's a subfunction) looks like
function [ODEfunction] = Compute_ODEfunction ... (time_start, phase_space_state, Particle_System, ~, x) phase_space_state = phase_space_state(:)'; Particle_System.set_phase_space_state (phase_space_state); Particle_System.aggregate_forces; NumParticles = length(Particle_System.particles); velocities = zeros(3*NumParticles,1); for i = 1:3*NumParticles velocities(i) = x(i+3*NumParticles); end accelerations_without_drag = Particle_System.get_particles_accelerations; eta = 0.0081+5.55511*time_start; drag_force = -Particle_System.drag*6*pi*eta*10*10^(-6); accelerations = zeros(3*NumParticles,1); for i = 1:3*NumParticles accelerations(i) = accelerations_without_drag(i) + ... drag_force*x(i+3*NumParticles)/(2*10^(-13)); end ODEfunction = [velocities, accelerations]'; end
We hope someone has an idea of what we have messed up.
Best Answer