expme.m

来自「数字通信第四版原书的例程」· M 代码 · 共 27 行

M
27
字号
function [A2,A1,B1] = expme(v,d,h)
%EXPME	Used by LINSIM to calculate matrix exponentials.
%       This function calculates matrix exponentials using eigenvalue
%	decomposition for the special case when the A matrix is
%	singular.  It is not used when A has repeated eigenvalues.

%	Copyright (c) 1990-94 by The MathWorks, Inc.
%	Andrew Grace 11-12-90.
[n,dum] = size(v);
invv = inv(v);
d  = diag(d).';
de = exp(d*h);
A2 = real(v .* de(ones(n,1),:) *invv).';

[ind]  = find((abs(d)<1e-8));
on = ones(length(ind),1);
d(ind) = on;

d2 = (de - ones(1,n))./d;
d2(ind) = h*on;
A1 = real(v .*  d2(ones(n,1),:) * invv).';

d(ind) = on;
d3 = (d2 - h*ones(1,n))./d;
d3(ind) = h*h*0.5*on;
B1 = real(v .*  d3(ones(n,1),:) * invv).';

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?