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.">
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.">
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.">
[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.


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

Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir