Solution to second order differential equation
显示 更早的评论
I want to solve a second order differential equation which passes parameters to the ode solver. The parameters are column arrays and hence I used for loop in the function. I don't know if what I wrote is right or wrong. I am getting the solution. But I have no idea if it is right or wrong..
Is the code within the function right? I mean the syntax...
Thankyou...
The function is given below
function r = f1(tspan,y2,I,J,K,L,W)
r = zeros(2,1);
c = zeros(length(tspan));
r(1) = y2(2);
for n =2:length(tspan)
c(n) = -(I(n).*y2(2) + J(n).*y2(1) + K(n) + L(n).*cos(W*tspan(n)));
end
r(2)=c;
1 个评论
Azzi Abdelmalek
2013-10-18
And how did you call this function?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!