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

Learn moreOpportunities for recent engineering grads.

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

Asked by KK on 12 May 2013

Hi,

I am using Matlab2008 and I have this problem : "Attempted to access lambda(160); index out of bounds because numel(lambda)=1."

This is my program code:

clear all n=1000; a=input('a: '); b=input('b: '); Y(1)=input('Y(1)= '); C(1)=a+b*Y(1); G=input('G: '); I=input('I: '); E(1)=C(1)+I+G; lambda=input('lambda: '); delY(2)=lambda(E(1)-Y(1)); %Ys=(a+I+G)/(1-b); for t=2:n C(t)=a+b*Y(t); delY(t+1)=lambda(E(t)-Y(t)); Y(t+1)=lambda(a+I+G)+[1-(lambda(1-b))]*Y(t); end; time=1:1:n; figure plot(time,Y) xlabel('t') ylabel('Y(t)')

Does anyone know what this problem relates to?

Thanks in advance.

*No products are associated with this question.*

Answer by Walter Roberson on 14 May 2013

What response is the user expected to give to

lambda=input('lambda: ');

??

Do you understand that lambda(E(1)-Y(1)) means to access the array named "lambda" at the index which has been calculated as E(1) minus Y(1) ?

## 0 Comments