integral of a matrix
105 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
raha ahmadi
el 19 de Jun. de 2021
Comentada: raha ahmadi
el 19 de Jun. de 2021
I want to take the integral of an exponetial of a matrix but I got this error and dont know how fix it:
'Unable to perform assignment because the indices on the left side are not compatible with the size of
the right side.
Error in Untitled7 (line 12)
ggg(ss)=integral(fun,0,T,'ArrayValued',true);'
thanks in advance
clc
clear
close all
M=ones(3,3);
Dmat=[1;2;3];
fun=@(t)expm(-M.*t)*Dmat;
T=1e-2;
g=integral(fun,0,T,'ArrayValued',true);
4 comentarios
Walter Roberson
el 19 de Jun. de 2021
And when you do not have that (ss) in there, then no error message is emitted.
I notice your tags mention expm, which is the matrix exponential, but your code uses exp() which is element-by-element exponential.
Respuesta aceptada
Walter Roberson
el 19 de Jun. de 2021
format long g
M = ones(3,3);
Dmat = [1;2;3];
fun = @(t)expm(-M.*t)*Dmat;
T = 1e-2;
g = integral(fun,0,T,'ArrayValued',true);
g
Más respuestas (1)
Scott MacKenzie
el 19 de Jun. de 2021
You note:
I want to take the integral of an exponetial of a matrix
But,
exp(-M.*t)*Dmat;
is a vector, not a matrix. Try using the dot operator in your function definition:
exp(-M.*t).*Dmat;
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!