MATLAB: What is wrong with the code

errorindexingMATLAB

clc;
P=[72 72 78 90 112 132 148 149 135 122 104 93 81 77 77 78 81 85 86 86 86 83 79 77 75 73];
t=[0:40:1000];
% plot(t,P);
F=[P t];
Pinte=zeros(1,200);
for i=0:5:1000;
k=i/5;
Pinte(k)=interp1(t,P,i);
end
I keep getting the error "Subscript indices must either be real positive integers or logicals." What is the correct way to index here /?>

Best Answer

You start your for loop at i = 0. You compute k = i/5 so k = 0/5 so k = 0. You then try to use k as an index. Indexing at 0 is not permitted. You need to add one to your k.