second order differential equation with variable coefficient
3 ビュー (過去 30 日間)
古いコメントを表示
Hi,
As wrote in a previous question I have to solve the equation: d^2x/dt^2= (q/m)(E/v^2)
I have wrote the following code:
q=1; m=1; v=1; E=1;
rhs=@(z,x)[x(2);(q/m)*(E/v^2)];
[za, xa] = ode45(rhs, [0 100], [0 0]);
and it works fine.
The problem is that E for me is a function of z that I can write as:
Ez=zeros(1,100);
for i=1:1:100
if (i<=10 || i>=50)
Ez(i)=0;
else
Ez(i)=1;
end
end
I have found an example here: http://www.mathworks.it/help/techdoc/ref/ode23.html where is shown how to solve ode with time-dependent terms, but is is about a first order problem and I'm not able to write something similar for my second order problem... could you help me?
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!