Each problem must be worked entirely in MATLAB Refer to the

Each problem must be worked entirely in MATLAB Refer to the uploaded documents for formatting and organizational requirements for the report Quality of presentation (formatting, organization) is worth 2 points out of possible 25 points These are individual projects and absolutely no collaboration is permitted Write a script file that employs any combination of the flow control commands to generate the given matrix. B = [1 1 0 0 0 0 0 -2 2 0 0 0 -1 0 3 3 0 0 0 1 0 -4 4 0 0 0 -1 0 5 5 0 0 0 1 0 -6]

Solution


b = zeros(6,6);
k = 1;
for i=1:6
for j=1:6
if (j >= i && j <= (i+1))
if (mod(i,2) == 1 || j == (i+1))
b(i,j) = i;
else
b(i,j) = i*-1;
end
end
  
if(i >= 2 && j==(i-2))
b(i,j) = k;
k = k*(-1);
end
end
end
disp(b);

%-----------------------------------------------------------------------------------------------------------------------

>> matGen
1 1 0 0 0 0
0 -2 2 0 0 0
1 0 3 3 0 0
0 -1 0 -4 4 0
0 0 1 0 5 5
0 0 0 -1 0 -6

>>

 Each problem must be worked entirely in MATLAB Refer to the uploaded documents for formatting and organizational requirements for the report Quality of present

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site