The differential equation problem

1 view (last 30 days)
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
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.
Bugra
Bugra on 26 Feb 2015
i try to solve for 2 days but i dont need use ode45 or ode23.i try this but graph is blank
A=[0 6 -1;6 2 -16;-5 20 -10];
x0=[1;1;1]
for t=0:5
x=expm(A*t)*x0
plot(t,x)
hold on
end

Sign in to comment.

Accepted Answer

Star Strider
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
Bugra
Bugra on 26 Feb 2015
Thank you. I use clc and clear all work your code.
Star Strider
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.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming 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!