Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
高级会员
注册日期: 2019-11-21
帖子: 3,006
声望力: 66 ![]() |
![]()
我已经在Matlab中编写了此函数,以使用Shift K表示Box_Function(-a,+ a),该函数可以很好地工作为K> a,但是当a> K时,第13行的结果为负,并且我得到错误:
数组索引必须是正整数或逻辑值。 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 |
![]() |
![]() |