[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.
                                        
                                            
                                            JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
                                        
                                        China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
                                        
                                            How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w