简体   繁体   English

错误:“索引超出矩阵尺寸”

[英]Error: “Index exceeds matrix dimensions”

The following code works when I run it on its own: 当我单独运行以下代码时,它们会起作用:

range = multi_sptime(100,end);
binary_input = binary_input2(1:range);
ssignal = signal(1:range);
signal = ssignal;% input current
clear input2 
clear binary_input2
dbstop if error

However, when I add this for loop: 但是,当我添加此for循环时:

neurons=[1,2,4,6,8,10,15,20,25,30,35,40,50,100,200];
for ncell=neurons
...

I get the error below: 我收到以下错误:

??? Index exceeds matrix dimensions.
Error in int_idc20 (line 8)
ssignal = signal(1:range);

How do I fix it and what's going on? 我该如何解决它以及怎么回事?

First, I think you wanted to loop over the # of elements in neurons , so correct your for line with: 首先,我认为您想遍历neurons的元素数,因此请for以下方式更正您for行为:

for ncell=1:numel(neurons)

and then depending on what you want use ncell or neurons(ncell) in your loop. 然后根据需要在循环中使用ncellneurons(ncell)

Second, range is a scalar that looks for multi_sptime row # 100 last element, and apparently the number it spits is larger than the # of elements is signal . 其次, range是一个标量,它查找multi_sptime行#100的最后一个元素,显然它吐出的数量大于signal的元素数量。 Try to size(signal) to see what you have. 尝试调整size(signal)以查看所拥有的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM