Each problem must be worked entirely in MATLAB Refer to the uploaded documents f
ID: 3794845 • Letter: E
Question
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]Explanation / Answer
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
>>
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.