简体   繁体   English

MATLAB:如何从特定的复杂向量中制作Hermitean矩阵?

[英]MATLAB: How to make the Hermitean matrix from specific complex vectors?

Is given : 给出
stationary mass ms=1; 静止质量ms=1;
Eta-constant eta=0.45; Eta-常数eta=0.45;
variable number of repetitions, eg N=5; 可变重复次数,例如N=5;
omega OM=sqrt(ks/ms); 欧米茄OM=sqrt(ks/ms);
angular frequency om=eta*OM; 角频率om=eta*OM;
time period T=2*pi/om; 时间段T=2*pi/om;
upper bound TTT=1.5; 上限TTT=1.5;
variable for creating function t=0:0.001:TTT; 用于创建函数的变量t=0:0.001:TTT;

I made a function like that: 我做了这样的功能:

kt=zeros(size(t));
for j=1:2*N+1
    n= j-(N+1);    
    if n==0
        k(j)=ks/2;
    else
        k(j)=i/pi/n;
    end
    kt=kt+k(j)*exp(i*n*om*t);
end

It's a Sawtooth wave and there is my problem . 这是一个Sawtooth浪潮,我的问题 From the complex vector kt with value 1x1501 double I have to make the Hermitean matrix for variable N . 从具有值1x1501 double的复数向量kt,我必须使Hermitean矩阵为变量N. This means that N can be 5, can be 50, 100, etc. The matrix should look like (picture): 这意味着N可以是5,可以是50,100等。矩阵应该看起来像(图片): Hermitean矩阵

Where k1 is k for N=1, k0 is k for N=0 or k-1 is k for N=-1. 其中k1对于N = 1是k,对于N = 0,k0是k,或者对于N = -1,k0是k。 Size of matrix is 2*N+1 and 2*N+1. 矩阵的大小是2 * N + 1和2 * N + 1。

Thank you for your help and responding! 感谢您的帮助和回复!

That's a Toeplitz matrix , you can use the toeplitz command to generate the matrix above. 这是一个Toeplitz矩阵 ,您可以使用toeplitz命令生成上面的矩阵。 In the general case, this would have been written as: 在一般情况下,这将被写为:

H = toeplitz(kt(N:end), kt(1:N + 1))

where the first N values in kt correspond to k - N , ... k -1 , and the last N + 1 values are k 0 , ... k N . 其中kt中的前N个值对应于k - N ,... k -1 ,并且最后的N + 1个值是k 0 ,... k N. However, since H is Hermitian, this can be simplified to: 但是,由于H是Hermitian,因此可以简化为:

H = toeplitz(kt(N:end));

Try this code: 试试这段代码:

k=[1 2+i 3+i 4+i 5+i];
N=7;
M=diag(k(1)*ones(N,1));

for j=1:length(k)-1
    M=M+diag(k(j+1)*ones(N-j,1),j)+diag(conj(k(j+1))*ones(N-j,1),-j)
end;

Here N should be equal or greater than the length of k array 这里N应该等于或大于k数组的长度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM