Error "using symengine>@()0.0" in ODE Solver
1 view (last 30 days)
Show older comments
Hello,
I restarted everything I did from scratch and in the most simpliest way possible to recreate the same error I get in my much larger code. This error occurs when I make the B-field components functions instead of constants as the E parts are currently defined in this specfiic example. However, in my much larger code this error occurs when I just change the syntax of the ode set so if this error can be resolved here, perhaps then I can figure out why it's happening in the larger code set.
Error:
Error using symengine>@()0.0
Too many input arguments.
Error in reffun (line 14)
ode1 = Ex + s(2).*Bz(s(4),s(5),s(6)) - s(3).*By(s(4),s(5),s(6));
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in diffiqtest (line 7)
[t,S] = ode15s(@reffun,tspan,s0);
Here is the main code:
v0 = [0 0 0];
p0 = [0 0 0];
s0 = [v0 p0];
tspan = [0 5];
[t,S] = ode15s(@reffun,tspan,s0);
Function where ODEs are defined:
function refsolve = reffun(t,s)
Ex = 0;
Ey = 0;
Ez = 0;
persistent Bx By Bz
%Used so that the B-field function is only run once
if isempty(Bx)
[Bx, By, Bz] = B_test();
end
%Reference: s(1) = vx, s(2) = vy, s(3) = vz, s(4) = x, s(5) = y, s(6) = z
ode1 = Ex + s(2).*Bz(s(4),s(5),s(6)) - s(3).*By(s(4),s(5),s(6));
ode2 = Ey + s(3).*Bx(s(4),s(5),s(6)) - s(1).*Bz(s(4),s(5),s(6));
ode3 = Ez + s(1).*By(s(4),s(5),s(6)) - s(2).*Bx(s(4),s(5),s(6));
ode4 = s(1);
ode5 = s(2);
ode6 = s(3);
refsolve = [ode1; ode2; ode3; ode4; ode5; ode6];
end
B_test function:
function [Bx, By, Bz] = B_test()
%Bfieldstrength = 0.64; %In (Teslas)
Bfieldstrength = 0;
magvol = 3.218E-6; %In (m)
mu0 = (4*pi)*10^-7;
magnetization = (Bfieldstrength*magvol)/mu0;
syms x y z
m = [0,0,magnetization];
r = [x, y, z];
B = mu0*(((dot(m,r)*r*3)/norm(r)^5) - m/norm(r)^3);
Bx = matlabFunction(B(1));
By = matlabFunction(B(2));
Bz = matlabFunction(B(3));
end
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!