Solving the matrix dimention for expm function

조회 수: 2 (최근 30일)
Adrian Brown
Adrian Brown 2021년 5월 25일
댓글: Adrian Brown 2021년 5월 25일
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
Torsten
Torsten 2021년 5월 25일
If B is 5x1,
y(:,k1) = (expm(H*time(k1))*C).*B
should work.
Adrian Brown
Adrian Brown 2021년 5월 25일
@Torsten Really appreciate that from you.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by