target_gen.m

来自「target image program in zip file」· M 代码 · 共 42 行

M
42
字号
function target = target_gen(x)
%%Target generation:
%
%This is a fuction to use with conjunction with target_image_gen.
%It basic modify the size of target to simulate an aproach.

x = round(x);

if x/2-round(x/2) == 0
    x = x+1;
end

if x < 0        %Target not visible
    target = zeros(11,11);
elseif x > 11
    if x > 20   %Target visible
        target = 6*ones(11,11);
    else        %Max size, now increase radius of the target
        a = x - 10;
        b = 5 - (a-1)/2;
        q1 = zeros(b,b);
        q2 = 6*ones(b,a);
        target = [q1 q2 q1;
            6*ones(a,11);
            q1 q2 q1];
    end
else            %Increase size of target
    a = (x-1)/2;
    b = (11-x)/2;

    q1 = zeros(a,a);
    q2 = zeros(b,11);
    q3 = zeros(11-2*b,b);

    temp = [q1 6*ones(a,1) q1;
        6*ones(1,x);
        q1 6*ones(a,1) q1];

    target = [q2;
        q3 temp q3;
        q2];
end

⌨️ 快捷键说明

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