Index in position 1 exceeds array bounds (must not exceed 61)

1 visualización (últimos 30 días)
When I run my code I get the error Index in position 1 exceeds array bounds (must not exceed 61)
Error in neph_calibration_correction (line 9)
p=polyfit([nephzero(i,2) nephspan(i,2)],[0 11.15],1); %
What am I getting wrong here? I have gone through previous solutions but seems not working.
%% calculate neph slopes
load('neph_zero_span.mat');% nephzero nephspan
nephspan=nephspan([2:4 6:end],:);
spancoefs=zeros(length(nephspan),4).*nan;
for i=1:length(nephspan)
spancoefs(i,1)=nephspan(i,1);
p=polyfit([nephzero(i,2) nephspan(i,2)],[0 11.15],1); % red
spancoefs(i,2)=p(1);
p=polyfit([nephzero(i,3) nephspan(i,3)],[0 23.86],1); % green
spancoefs(i,3)=p(1);
p=polyfit([nephzero(i,4) nephspan(i,4)],[0 44.21],1); % blue
spancoefs(i,4)=p(1);
end

Respuesta aceptada

KSSV
KSSV el 7 de Dic. de 2021
This error occurs, when you try to extract more number of elements then present in the array.
A = rand(10,1) ;
A(1) % no error
ans = 0.4508
A(7) % no error
ans = 0.7545
A(11) % error as there is no 11th element
Index exceeds the number of array elements. Index must not exceed 10.
Check the dimensions of your variables.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing 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!

Translated by