Solving the matrix dimention for expm function

2 visualizaciones (últimos 30 días)
Adrian Brown
Adrian Brown el 25 de Mayo de 2021
Comentada: Adrian Brown el 25 de Mayo de 2021
Good afternoon,
I and working in the code bellow. I have an error message Arrays have incompatible sizes for this operation.
time=0:0.01:2*pi; %time vector
H=[0 1 0 0 0;1 0 0 0 0;0 0 1 0 1;0 0 0 1 1;0 0 1 1 0];
B = [2 ;-2 ];
C=[0.1 + 0.010i;0.2 + 0.0010i; 0.1 + 0.0020i;-0.4 + 0.001i;0.8 - 0.7i];
for k1 = 1:numel(time)
y(:,k1) = expm(H*time(k1))*C.*B;
end
figure(1)
plot(time,y)
grid
I really appreciate any help and suggestions
  4 comentarios
Torsten
Torsten el 25 de Mayo de 2021
If B is 5x1,
y(:,k1) = (expm(H*time(k1))*C).*B
should work.
Adrian Brown
Adrian Brown el 25 de Mayo de 2021
@Torsten Really appreciate that from you.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by