Evaluate matrix equation at multiple timesteps
Show older comments
How can I evaluate a matrix equation at multiple timesteps? I've defined the following:
R=[1 0.5; 0.5 1];
M0=[1;1];
u0=[1;0];
x=linspace(0,1,100)
f=@(x) expm(-R.*x)*(u0-M0) + M0;
y=feval(f,x);
However, this gives an error as x is the 'wrong size' for matrix multiplication. However, I don't want to do matrix multiplication, but instead evaluate f at every value of x.
2 Comments
Even if x is a scalar, your code produces multiple y values:
>> x = 1;
>> expm(-R.*x)*(u0-M0)
ans =
0.19170
-0.41483
Is this correct? Or do you expect one y value for each x value?
Mark
on 11 Jan 2019
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics 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!