MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   MatLab生成框函数时负索引的错误 (https://www.labfans.com/bbs/showthread.php?t=22230)

poster 2019-11-28 17:20

MatLab生成框函数时负索引的错误
 
我已经在Matlab中编写了此函数,以使用Shift K表示Box_Function(-a,+ a),该函数可以很好地工作为K> a,但是当a> K时,第13行的结果为负,并且我得到错误:

[B]数组索引必须是正整数或逻辑值。 [/B]

function B_X = Box_Func(N,K,a) % Heaviside This Function takes Number of Samples N and the % shift K and stem Them , Note it works only for positive shifting % that means K should be positive or Zero if(N N) % if samples Number wrong, or shifting exceeds limit % of Samples Print a warning. warning('Please Enter Valid Positive Integer !'); else % if The inputs are fine , then : B_X = zeros([-NN]); % Allocation of Zero array to our Function Output. for i = -N : 1 : N % Defining Range from -N to N instead of just 1-N % to make plotting more clear to understand. if (i >= Ka) && (i


所有时间均为北京时间。现在的时间是 22:43

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.