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.)
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)
Part 2: Solve the following problems in MATLAB 1. Fill in the function E = myElim(A,...
Part 2: Solve the following problems in MATLAB 1. Fill in the function E = myElim(A, r_entry, r_pivot, c) to create an m by m elimination matrix ??. Remember that an elimination matrix looks like an identity matrix with one extra entry of ?? in row r_entry and column r_pivot. 2. Fill in the function M = myMult(A, c_pivot) to create an m by m multiplier matrix ??. Remember that a multiplier matrix looks like an identity matrix with the...
Consider the magic matrix: A = np.array([[17, 24, 1, 8, 15],                          [23, 5, 7, 14, 16],...
Consider the magic matrix: A = np.array([[17, 24, 1, 8, 15],                          [23, 5, 7, 14, 16],                          [ 4, 6, 13, 20, 22],                          [10, 12, 19, 21, 3],                          [11, 18, 25, 2, 9]]) The matrix A has 5 row sums (one for each row), 5 column sums (one for each column) and two diagonal sums. These 12 sums should all be exactly the same. Verify that they are the same by printing them and “seeing” that they are the same.
Create a function x=backsub(U,y) in matlab that accepts as input arguments a nxn matrix U and...
Create a function x=backsub(U,y) in matlab that accepts as input arguments a nxn matrix U and n-vector y, and returns as output a column vector x consisting of the values of the unknowns x1; x2; : : : ; xn.
create program using matlab, that displays number of (+) entries (=>0) in matrix and number of...
create program using matlab, that displays number of (+) entries (=>0) in matrix and number of negative (<0). Hard code matrix in program. Use nested loops and an if-else-end structure to count (+) and (-) entries. Program should display original matrix and number of positive/negative entries.