Why am I getting "Index in position 2 exceeds array bounds. Index must not exceed 1"
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rezaul Reza
el 29 de Dic. de 2021
Editada: Cris LaPierre
el 31 de Dic. de 2021
This is my import function
When I load the music it says this. However, if i remove these the program works fine. But i need to extract both channels
rightChannel = y(:, 2);
this is supposed to extract the right channel, right? If so, then why am I getting
Index in position 2 exceeds array bounds. Index must not exceed 1.
0 comentarios
Respuesta aceptada
Cris LaPierre
el 29 de Dic. de 2021
Editada: Cris LaPierre
el 29 de Dic. de 2021
You haven't shared the complete error message, so I'm not sure what line is causing the error, but it is most likely this one:
app.y(:, 2)
The error itself is easy to explain. You are trying to index the second column of a variable that only has one column. Consider the following example.
A = rand(5,1)
% Works
A(2,1)
% Doesn't work
A(1,2)
7 comentarios
Cris LaPierre
el 29 de Dic. de 2021
Editada: Cris LaPierre
el 29 de Dic. de 2021
1. give it a different name
2. Generally in an app, it is preferable to not use 'input', as the whole idea behind an app is to have everything be contained there. Use an Edit Field component and query the value.
startpnt = app.StartEditField.Value
Generally speaking, once an answer has been accepted, it is best to ask a new question, especially if the new questions are unrelated to the original.
Cris LaPierre
el 29 de Dic. de 2021
Editada: Cris LaPierre
el 31 de Dic. de 2021
That was made up example code. You have to use your actual variable and component names. Capitalization matters.
app.startpnt = app.STARTEditField.Value
EDIT: This thread may now seem confusing to follow. The OP has deleted several comments and reworded those that are still here, making it so the replies no longer appear to align with the questions.
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices 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!
