Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
 
 
主题工具 显示模式
旧 2019-11-28, 17:20   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 MatLab生成框函数时负索引的错误

我已经在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
poster 当前离线   回复时引用此帖
 


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



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


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