MATLAB: Index out of bounds

index out of bounds

Hi guys,
I need your help once more!
The error is: index out of bounds because size(z)=[22719,1];
So this is my code where things go wrong:
X = [ones(M,1), z(:,t) z(:,t).^2];
and this is the error:
Attempted to access z(:,19); index out of bounds because size(z)=[22719,1].
Any help would be appreciated.
Thanks!

Best Answer

The problem is clear
The size of z is [22719,1], which means z(:, 19) does not exist