I am applying for loop on a variable n to get corresponding matrices against each value of n but Matlab only uses the last value of n and gives the single matrix. Will be grateful to anyone who can help
if true % code
Nt=3;Nm=-3;b=0.5;%Define E(j,k)
for k=0:Nt-1 for j=0:Nt-1 if j~=k e(j+1,k+1)= 0; elseif j==k~=0 e(j+1,k+1)= pi/2; else e(j+1,k+1) = pi; end %Define D(j,k)
if mod(abs(k-j),2)==0 d(j+1,k+1)= pi/2*k*(k^2-j^2); else d(j+1,k+1)=0; end %Define A(n) matrix
for n=-3:3 if j<=Nt-3 a(j+1,k+1)=-(n*b)^2*e(j+1,k+1)+d(j+1,k+1); elseif j==Nt-2 a(j+1,k+1)=1; else a(j+1,k+1)=(-1)^k; end end endendend
Best Answer