Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Index out of bounds

Asked by Kevin van Berkel on 30 May 2013

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!

0 Comments

Kevin van Berkel

Products

No products are associated with this question.

2 Answers

Answer by Azzi Abdelmalek on 30 May 2013
Accepted answer

The problem is clear

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

2 Comments

Azzi Abdelmalek on 30 May 2013

Kevin's comment

Thanks for your reply Azzi.

So how should I adjust my code?

Azzi Abdelmalek on 30 May 2013

Maybe this is what you want, but I'm not sure, you have to tell us.

X = [ones(M,1);z(t,1) ;z(t,1).^2];
Azzi Abdelmalek
Answer by Kevin van Berkel on 1 Jun 2013

Works now. Thanks Azzi!

0 Comments

Kevin van Berkel

Contact us