Attempted to access lambda(160); index out of bounds because numel(lambda)=1.

1 次查看(过去 30 天)
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.

回答(1 个)

Walter Roberson
Walter Roberson 2013-5-14
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) ?

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by