Question

MATLAB:: Create a matrix with one through 15 on the diagonal. First create a one row...

MATLAB:: Create a matrix with one through 15 on the diagonal. First create a one row 15 column matrix with 1 through 15 in it. Then use the “diag” command .

Homework Answers

Answer #1

% Matlab script to create a matrix with one through 15 on the diagonal.

% create a row vector from 1 to 15 in steps of 1
v = (1:15);
% diag command to place the elements of input vector v in the main diagonal of a
% square matrix of size number of elements in v and the other elements of
% the matrix are 0.
diagonal_1_15 = diag(v);
% display the resultant matrix
disp(diagonal_1_15);

%end of script

Output:

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
Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1...
Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1 on the super- and sub-diagonal. Then replace the (1,1) element of A with a 1. (Make your commands capable of handling an arbitary sized NxN matrix by first defining N=5, then using the variable N as the size in each of the commands.)
Exercise 1: Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal,...
Exercise 1: Write MATLAB code to create a 5x5 matrix A with 2's on the diagonal, and -1 on the super- and sub-diagonal. Then replace the (1,1) element of A with a 1. (Make your commands capable of handling an arbitary sized NxN matrix by first defining N=5, then using the variable N as the size in each of the commands.)
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...
MATLAB Create a matrix E, using A and B vectors as row 1 and row 2...
MATLAB Create a matrix E, using A and B vectors as row 1 and row 2 respectively A = 10 thru 1 B = 1 thru 4.2 with ten equally spaced elements and Find the indices (row and col) within E where (prob02a, b, c, d) E = 5 E > 4 E < 1.9 E > 1 and E < 2
Write a code in matlab for going through every element in a imported image matrix that...
Write a code in matlab for going through every element in a imported image matrix that has been gray scaled using for loops (going through every row and column) and changing every element that is equal to 255 to 1 and every number less then 255 equal to 0. Then find the x and y coordinate of each element now equal to 0 in that image matrix once again going through each row and column.
I need code for a problem in Matlab Create a single Matlab script that accomplishes the...
I need code for a problem in Matlab Create a single Matlab script that accomplishes the following: Defines a blank tic tac toe board, a 3 x 3 matrix, called board with blank spots represented by zeros. Asks player 1 for a row and column, then puts 1 in a given location. Asks player 2 for a row and column, then puts 2 in a given location
using matlab: Q)using nested for loops to generate a 3*3 matrix where the element value is...
using matlab: Q)using nested for loops to generate a 3*3 matrix where the element value is equal to the sum of its row and column number, except for the diagonal elements which are zeros
Nested For Loops a. Create a 10×15 matrix with NAs. b.Assign [i,j] th element( ith row...
Nested For Loops a. Create a 10×15 matrix with NAs. b.Assign [i,j] th element( ith row and jth column value ) as i × j by using nested for loops. Provide R code Plz
please do on matlab Create the 10×10 elementary matrix E that would switch the rows 3...
please do on matlab Create the 10×10 elementary matrix E that would switch the rows 3 and 7. Do not enter the matrix manually, but use the command eye to create the identity matrix and modify the appropriate entry. For instance >> E(3,3)=0 with change the (3, 3) entry of E to 0. Test your matrix with a random 10 × 10 matrix.
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)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT