Evaluate matrix equation at multiple timesteps
Mostrar comentarios más antiguos
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 comentarios
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
el 11 de En. de 2019
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Mathematics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
