The differential equation problem
1 view (last 30 days)
Show older comments
i have a question but i dont solve it. i am beginner for matlab. i think that doesnt exist. do u have an idea?
2 Comments
John D'Errico
on 26 Feb 2015
What doesn't exist?
Why not make an effort? Begin to learn, as that is the only way you will learn.
I'll give you a hint. There are many tools like ODE45 to solve simple ODEs of this form. But it appears here that you are expected to use expm. So try it.
Accepted Answer
Star Strider
on 26 Feb 2015
You’re almost there, so I’ll provide the corrected loop. You have to index the output of a loop or you only get the last value. In this instance, it’s a bit more challenging, because the output is a column vector, so you have to provide for that, and index the output by rows.
Consider:
A=[0 6 -1;6 2 -16;-5 20 -10];
x0=[1;1;1];
t=linspace(0,5);
for k1 = 1:length(t)
x(:,k1)=expm(A*t(k1))*x0;
end
figure(1)
plot(t,x)
grid
4 Comments
Star Strider
on 26 Feb 2015
My pleasure!
The .m-file I use to test my code for Answers clears my workspace automatically, so I sometimes forget to suggest it.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!