Index exceeds the number of array elements. Index must not exceed 272.

2 visualizaciones (últimos 30 días)
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

Respuestas (2)

David Hill
David Hill el 17 de Nov. de 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.
  1 comentario
Felicia DE CAPUA
Felicia DE CAPUA el 17 de Nov. de 2022
I need to try the correlation about spectrum_1 and spectrum_2 bewteen this time series (namely time_power).

Iniciar sesión para comentar.


Torsten
Torsten el 17 de Nov. de 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 comentarios
Torsten
Torsten el 17 de Nov. de 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).

Iniciar sesión para comentar.

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by