How to iterate across a specific diagonal?
4 views (last 30 days)
Hello, I am a beginner to matlab and wondering if anyone can help me with this specific problem. Here is my code
HM = zeros(n);
% upper t diagonal
for ii = (N1*N2*nband):n
HM(ii,n+1-ii) = t
What I am trying to do is get a diagonal of 4's or the t variable across the the half diagonal of the matrix. Here is an image for reference. It must work for all values of N1 and N2. For example, if N1 =3, N2=2, then I would like the 8th diagonal to be iterated through the t variable. It is basically half of the n dimension. I am stuck. Any help is appreciated if possible! Thank you so much