简体   繁体   English

我在 matlab_Index 中收到此错误,超出了数组元素的数量。 索引不得超过 1

[英]I am getting this error in matlab_Index exceeds the number of array elements. Index must not exceed 1

I put 7 rows and 7 columns in A to make a 7x7 matrix, but I don't know why an error occurs.我在 A 中放了 7 行 7 列组成一个 7x7 矩阵,但不知道为什么会出现错误。 enter image description here在此处输入图像描述

In MATLAB, the 'index exceeds matrix dimensions error' is encountered when you try to access an element which is not present in the array or matrix.在 MATLAB 中,当您尝试访问数组或矩阵中不存在的元素时,会遇到“索引超出矩阵维度错误”。

As an example, consider the following code:例如,考虑以下代码:

m = zeros(7,7) ; % creates a 7x7 matrix filled with zeros
m(3,3) = 1 ;     % sets one element to 1
m(3,3) % Prints '1' in the output console

% ! The following line produces an error !
m(8,1) % Throws an 'index exceeds matrix dimensions' error! 

If you shared a sample of the code you are struggling with, it would be easier for me to help you solve the problem.如果您分享了您正在努力解决的代码示例,我将更容易帮助您解决问题。

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

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