Question

Generate a 4 x 4 random integer matrix, save it in the variable mat and perform...

Generate a 4 x 4 random integer matrix, save it in the variable mat and perform the following: ( MATLAB)

  1. Generate a matrix from the matrix mat that is composed of row 2, row 1 and row 3 of mat
  2. Generate a matrix from the matrix mat that is composed on column 2 and 3 of mat
  3. Generate a matrix from the matrix mat that starts with column 2 and row 3 and contains all the elements till the end.

Homework Answers

Answer #1

Generate a 4 x 4 random integer matrix, save it in the variable mat and perform the following:

>>mat=magic(4)

Generate a matrix from the matrix mat that is composed of row 2, row 1 and row 3 of mat

>>mat2 = mat(1:3,)

Generate a matrix from the matrix mat that is composed on column 2 and 3 of mat

>>mat3=mat(,2:3)

Generate a matrix from the matrix mat that starts with column 2 and row 3 and contains all the elements till the end.

>>mat4=mat(3: , 2: )

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Create a matrix 4x4 of integer random numbers between 1 and 50, and perform the following...
Create a matrix 4x4 of integer random numbers between 1 and 50, and perform the following operations: a. Generate a (1x3) matrix of the original b. Generate a (4x2) matrix of the original with the row order reversed c. Replace the second column of the matrix with [4; 8 ; 16; -2] ( MATLAB)
let us create a variable for a row vector a = [1, 4, 1, 3, 2,...
let us create a variable for a row vector a = [1, 4, 1, 3, 2, 5, 0] and calculate the mean value of its elements using the Matlab function ‘mean’ and store this value in variable aMean. Fig. 1 gives the Matlab code to do this. a = [1, 4, 1, 3, 2, 5, 0]; aMean = mean(a); Figure 1: Matlab code – row vector and mean of its elements. Let us now construct a row vector b that...
1. Given a matrix variable "mat", write code using for loops, if statements, etc. that will...
1. Given a matrix variable "mat", write code using for loops, if statements, etc. that will accomplish the same as the following: matsum = sum(mat') Please make sure to store the result in "matsum" and dont use sum. This is what I have so far but it keeps telling me is wrong.... % mat has been initialized for you: mat = randi([-100,100],randi([15,20]),randi([15,20])); % write your statements that accomplish the code above: [r c]=size(mat); for i=1:c matsum=0; for j=1:r matsum=matsum+mat(j,i); end...
Matlab Queatoin: The test suite generates a random M x N matrix with a random number...
Matlab Queatoin: The test suite generates a random M x N matrix with a random number of rows and columns that is assigned to the variable A . The element values of the matrix are random double precision numbers that fall in the range from -10 to 10. The matrix has between 5 and 10 rows and between 5 and 10 columns. Assuming A is defined in the workspace, write a script with commands to perform the operations described below...
All these to be done in MATLAB: 1.1)Define a column vector, called “b” in MATLAB that...
All these to be done in MATLAB: 1.1)Define a column vector, called “b” in MATLAB that stored floating point numbers between 0.6 to 2.5 in increment of 0.2. 1.2)What is the size of vector b? How is the size of ‘b’ stored? Define number of rows of ‘b’ in variable ’row’ and number of columns of “b” in variable “col”. 1.3)Define matrix “A” as a 10 by 10 matrix of all “1”s. 1.4)Update matrix “A” as following: set all the...
how do you generate data for a y random variable in matlab? If x has uniform...
how do you generate data for a y random variable in matlab? If x has uniform distribution (0,1) y has uniform distribution (a,b) Then write a matlab code using rand() command to generate data from distribution of y y = ? + ?x a,b, rand()
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except...
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except for 1s on the reverse diagonal from top right to bottom left. The reverse diagonal of an n-by-n matrix consists of the elements at the following indexes: (1, n), (2, n-1), (3, n-2), … (n, 1). The function takes one positive integer input argument named n, which is the size of the matrix, and returns the matrix itself as an output argument. Note that...
Let X be a discrete random variable with positive integer outputs a show that p (X=...
Let X be a discrete random variable with positive integer outputs a show that p (X= K)= P( X> K-1) - P( X> k) for any positive integer k b Assume that for all k >I we have P (X>k)=q^k  use l() to show that X is a geometric random variable
In the code space provided in Matlab Grader, create a function that: 1. Accepts an input...
In the code space provided in Matlab Grader, create a function that: 1. Accepts an input matrix A as its only input argument. Matrix A is a 3x3 matrix of random integers between 1 and 4 2. Produces and output matrix B as its only output argument. Matrix B will also be a 3x3 matrix. 3. Calculates the elements of matrix B such that: a. the values of B along the diagonal are equal to the respective elements in A...
PLEASE USE MAT LAB ONLY. THANK YOU (a) Create and plot the signals listed below and...
PLEASE USE MAT LAB ONLY. THANK YOU (a) Create and plot the signals listed below and save your Matlab code in a script file. i) Cosine signal of frequency 100 Hz over the range [0,0.1] seconds and samples spaced 10^- 4 seconds apart with a phase of pi/2 and an amplitude of 1.   PLEASE USE MAT LAB ONLY. THANK YOU ii) A square wave that oscillates between 0 and 1 every five samples, plot 3 periods of the waveform. iii)...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT