[code]function[output]=tridiag(d,l,r)
A=zeros(3);
for i=1:5
A(i,i)=d(i);
for j=2:5
A(j,(i-1))=l(j);
for k=1:4
A(k,(i+5))=r(k);
end
end
end
A
end[/code]
on this part where it says,[code]for j=2:5
A(j,(i-1))=l(j);[/code]
I want the variable "i" to execute from 1 ~ 4. and not 5. That's why I put i-1 there, but obviously it won't work.How can I make the nested j-loop to repeat i=1:4, instead of i=1:5? Same question goes for k-loop too.
+update: So I want the outside i-loop to perform from 1:5, but for the inner j-loop, i want i=1:4.