Why am I getting "Index in position 2 exceeds array bounds. Index must not exceed 1"
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Rezaul Reza
il 29 Dic 2021
Modificato: Cris LaPierre
il 31 Dic 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 Commenti
Risposta accettata
Cris LaPierre
il 29 Dic 2021
Modificato: Cris LaPierre
il 29 Dic 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 Commenti
Cris LaPierre
il 29 Dic 2021
Modificato: Cris LaPierre
il 29 Dic 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
il 29 Dic 2021
Modificato: Cris LaPierre
il 31 Dic 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Antennas, Microphones, and Sonar Transducers in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!