Why am I getting "Index in position 2 exceeds array bounds. Index must not exceed 1"
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rezaul Reza
am 29 Dez. 2021
Bearbeitet: Cris LaPierre
am 31 Dez. 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 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 29 Dez. 2021
Bearbeitet: Cris LaPierre
am 29 Dez. 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 Kommentare
Cris LaPierre
am 29 Dez. 2021
Bearbeitet: Cris LaPierre
am 29 Dez. 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
am 29 Dez. 2021
Bearbeitet: Cris LaPierre
am 31 Dez. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
