how to create this matrix?

Illustration
diadalina - 2023-03-17T13:45:23+00:00
Question: how to create this matrix?

can anyone help me to construct this matrix     blj=(-2)^j-l if lj  

Expert Answer

Profile picture of Prashant Kumar Prashant Kumar answered . 2025-11-20

I think it would look something like this...

 

iLength = 5; %rows
jLength = 7; %cols

b=zeros(iLength, jLength);

for i = 1:iLength
    for j = 1:jLength
        if i == j; b(i,j) = 1; end
        if i < j; b(i,j) = (-2)^(j-i); end
    end
end

disp(b)
            

gives a result of:

     1    -2     4    -8    16   -32    64
     0     1    -2     4    -8    16   -32
     0     0     1    -2     4    -8    16
     0     0     0     1    -2     4    -8
     0     0     0     0     1    -2     4

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!