Question
can you please help me with this question please. it's matlab. Thank you so much Step 1. Write one command to create the matrix below.
can you please help me with this question please.
it's matlab. Thank you so much
Step 1.
Write one command to create the matrix below. Do not hardcode
individual elements into the matrix.
mat_Q1 =
6 6 6 6 6 6 6
6 6 6 6 6 6 6
6 6 6 6 6 6 6
6 6 6 6 6 6 6
6 6 6 6 6 6 6
6 6 6 6 6 6 6
6 6 6 6 6 6 6
Step 2.
Using array indexing,
a) Replace the inner 5x5 matrix with 5s with one command.
b) Replace the inner 3x3 matrix with 2s with one command.
c) Replace the innermost value with 1 with one command.
Do not use any looping structures.
Your matrix should now look like this:
mat_Q1 =
6 6 6 6 6 6 6
6 5 5 5 5 5 6
6 5 2 2 2 5 6
6 5 2 1 2 5 6
6 5 2 2 2 5 6
6 5 5 5 5 5 6
6 6 6 6 6 6 6
Step 3.
Using array indexing,
a) Copy a row vector from mat_Q1 that contains these values in this order
using one command:
A = 1 2 5 6
b) Copy a row vector from mat_Q1 that contains these values in this order
using one command:
B = 5 2 1
c) Copy a column vector from mat_Q1 that contains these values in this order
using one command:
C =
1
2
5
6
d) Copy a column vector from mat_Q1 that contains these values in this order
using one command:
D =
5
2
1
Do not hardcode any values from mat_Q1; assign the new vectors to the variables given.
Step 4.
Using only the vectors A, B, C, and/or D and array indexing,
write a set of commands to replace the exterior rows and columns
of mat_Q1 so that the new matrix looks like
mat_Q1 =
1 2 5 6 5 2 1
2 5 5 5 5 5 2
5 5 2 2 2 5 5
6 5 2 1 2 5 6
5 5 2 2 2 5 5
2 5 5 5 5 5 2
1 2 5 6 5 2 1
Step 5.
a) Write one command that sums each column in mat_Q1 using a built-in function.
Assign the output to a variable named W.
b) Write one command that sums each row in mat_Q1 using a built-in function.
Assign the output to a variable named X.
c) Write one command that sums all elements in mat_Q1 using a built-in function.
Assign the output to a variable named Y.
d) Write one command to concatenate Y to the bottom of X. Assign
the result to a variable named Z.
Step 6.
Expand the size of mat_Q1 by concatenating it with the sum vectors X and Y.
a) Concatenate W to the BOTTOM of mat_Q1. Use the square brackets
to perform the concatenation with one command.
b) Concatenate Z to the RIGHT of mat_Q1. Use the square brackets
to perform the concatenation with one command.
Your final matrix should now look like this:
mat_Q1 =
1 2 5 6 5 2 1 22
2 5 5 5 5 5 2 29
5 5 2 2 2 5 5 26
6 5 2 1 2 5 6 27
5 5 2 2 2 5 5 26
2 5 5 5 5 5 2 29
1 2 5 6 5 2 1 22
22 29 26 27 26 29 22 181
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started