What is wrong with my code?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hammer_data16 = importdata('10_24_2022m002_a_hammer_16dat.txt');
hammer_time16 = hammer_data16(:,1);
hammer_out16 = hammer_data16(:,3);
hammer_in16 = hammer_data16(:,2);
It is telling me "Index in position 2 exceeds array bounds. Index must not exceed 1".
0 comentarios
Respuestas (1)
Askic V
el 11 de Nov. de 2022
Execute command:
[r,c] = size(hammer_data16)
To see actual dimensions of the matrix hammer_data16 and then you'll see where the problem is. In order to diagnose further, more data is needed such as '10_24_2022m002_a_hammer_16dat.txt' file and the data line where Matlab interpreter reports the error.
But you'll probably figure it out yourself when you look at r and c variables.
2 comentarios
Askic V
el 11 de Nov. de 2022
Editada: Askic V
el 11 de Nov. de 2022
I think you now see the problem. if c is 1 it means it has only one column (in fact since r is also 1, it is only a number).
In line
hammer_out16 = hammer_data16(:,3);
you're trying to read all elements in the third column hence index is exceeded, because there is no third column of the data.
Please attach your source data file that you read into hammer_out16, because nothing is wrong with your code, the data in the file is the most likely a problem, especially if only one numer is read from the data file.
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!