1 view (last 30 days)
I have to solve two differential equation and I have used the following code:
inits='y(0)=0, Dy(0)=0, x(0)=0, Dx(0)=0';
[y,x]=dsolve('D2y=(q*B)/(m_H*v_H)', 'D2x=(q*E)/(m_H*v_H^2)', inits,'z');
The problem I have is that B and E, magnetic and electric field, are defined in a certain region, let' say:
B=1 if 0<=z=<15 cm
E=1 if 8<=z<=16 cm
E=B=0 outside these regions.
Basically E and B have hard-edge shape and are parallel and both othogonal to z direction.
Moverover I want to solve the equations for a longer path, let's say z=40cm where I have an imaging device.
How can I deal with those field?
It would be better to use an ode solver and rewrite the code as:
[z,x] = ode23(odefun1,[z0,zf],x0,options)
and another one for the other equation, giving the field shape in the option?