dirfun.m

来自「由切比雪夫权值矢量及阵元间距画波束方向图:有x输入」· M 代码 · 共 38 行

M
38
字号
function [spec, theta,phase]=dirfun(weight,dspace,x)
%计算方位响应,画方向图
%有x输入,计算该方向的值,否则计算所有方向的值
%[spec theta]=dirfun(weight,dspace,x)
[m sensor]=size(weight);
if ~exist('x')
    theta=(-90:.1:90)';
    w=theta/180*pi;
    phi=2*pi*dspace*sin(w);
    sc=0:sensor-1;
    si=exp(j*(phi*sc));
    %方向图
    energe=si*weight.';%/sensor
    spec=10*log10(abs(energe).^2);
    figure;
    ghd=plot(theta,spec);
    set(ghd,'color','r');
    grid on; 
    zoom on;hold on;
    figure(gcf);
else
    [k s]=size(x);
    if k==1
        theta=x.';
    else
        theta=x;
    end
    w=theta/180*pi;
    phi=2*pi*dspace*sin(w);
    sc=0:sensor-1;
    si=exp(j*(phi*sc));
    %方向图
    energe=si*weight.';%/sensor

end

    spec=10*log10(abs(energe).^2);
    phase=angle(energe);

⌨️ 快捷键说明

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