Index exceeds the number of array elements. Index must not exceed 272.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi everyone,
I have a problem with my code.
This is my code:
plot_power = [872 1016];
time_power = plot_power(1):bin:plot_power(2);
mean_value_data_smooth_1 = mean_value_data_smooth_1.';
mean_value_data_smooth_2 = mean_value_data_smooth_2.';
spectrum_1 = mean_value_data_smooth_1(time_power);
spectrum_2 = mean_value_data_smooth_2(time_power);
the time power is a vector 1x15, while the spectrum_1 and spectrum_2 are a vectors 272x1.
The error is: Index exceeds the number of array elements. Index must not exceed 272.
I don't understand. How can I resolve this???
Thank you so much
2 Kommentare
Antworten (2)
David Hill
am 17 Nov. 2022
What are you trying to do? You cannot index into mean_value_data_smoth with a value greater than its size (272). You are indexing into it with values from 872 to 1016. If you tell us what you are trying to do, big picture, we might be able to help.
Torsten
am 17 Nov. 2022
mean_value_data_smooth_1 and mean_value_data_smooth_2 only have 272 elements.
Thus the values of the array elements of "time_power" in the assignments
spectrum_1 = mean_value_data_smooth_1(time_power);
spectrum_2 = mean_value_data_smooth_2(time_power);
must lie between 1 and 272.
But they lie between 872 and 1016 by setting
plot_power = [872 1016];
time_power = plot_power(1):bin:plot_power(2);
This will throw the error that the indices of mean_value_data_smooth_1 and mean_value_data_smooth_2 exceed 272.
7 Kommentare
Torsten
am 17 Nov. 2022
Then you must find the index range (between 1 and 272) in mean_value_data_smooth_1 and mean_value_data_smooth_2 that corresponds to the time range (between 872 and 1016).
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!