Question

In: Computer Science

A. Write a function in MATLAB called findTranspose that takes in as input any matrix or...

A. Write a function in MATLAB called findTranspose that takes in as input any matrix or any vector and simply returns back the transpose of that input. You can always verify your answer by using the inbuilt transpose function in MATLAB, however, you cannot use the transpose function directly when writing your code. Here is the starter code that we are providing to help you get started

%x is the input vector or matrix. You can find the

%size that is the number of rows and the number

%of columns of x by using the size function in MATLAB function transpose_ret = findTranspose(x)

. . .

%transpose_ret is the variable that will contain the transpose of the input x end

Solutions

Expert Solution

Matlab function can be defined with the help of number of rows and number of columns which is given as input to justify the size of the matrix and also input of the matrix x.This can be done by giving input of any matrix or any vector.

MATLAB code snippet

r = input('Enter the no. of rows');

c = input('Enter no. of columns');

function transpose_ret = findTranspose(x)

[r c] = size(x);

transpose_ret = zeros(c,r);

for i = 1:r

for j = 1: c

transpose_ret(j,i) = x(i,j)

end

end

end

x = [1 3;2 5]; %x is given as input 2x2 matrix

transpose_ret = findTranspose(x); % transpose the matrix x

transpose_ret

OUTPUT 
Enter the no. of rows> 2
Enter no. of columns> 2
transpose_ret =

   1   0
   0   0

transpose_ret =

   1   0
   3   0

transpose_ret =

   1   2
   3   0

transpose_ret =

   1   2
   3   5

transpose_ret =

   1   2
   3   5

This can also be verified by using the transpose function

x = [1 3;2 5]; %x is given as input 2x2 matrix
transpose(x)

OUTPUT

ans =

   1   2
   3   5

Related Solutions

B. Write a function in MATLAB called findInverseOf2x2Matrix that takes in as input any square matrix...
B. Write a function in MATLAB called findInverseOf2x2Matrix that takes in as input any square matrix of size 2 × 2 and returns back the inverse of that matrix if one exists. If no inverse exists, print back a suitable error message. You can safely assume that we will test your code on square matrices of size 2 × 2 only. You can always verify your answer by using the inbuilt inverse function in MATLAB, however, you cannot use the...
Write a Matlab function for a matrix that takes in a matrix in echelon form and...
Write a Matlab function for a matrix that takes in a matrix in echelon form and will return the row canonical form. The function cannot use rref, or any other matlab built in functions.
Write a Matlab function called “SimpleChannel” which takes a signal as an input, simulates a channel...
Write a Matlab function called “SimpleChannel” which takes a signal as an input, simulates a channel and returns the transmitted signal.. SimpleChannel function will add a randomly generated noise (look for “rand” function) to the signal and return it. You can adjust the amplitude of the noise as you want in order to have a distinct noise effect. Then write another matlab code to show the channel noise. First create the signal and then simulate the channel by using your...
MATLAB Function: (Backward substitution) Write a function that takes an upper triangular matrix U, and a...
MATLAB Function: (Backward substitution) Write a function that takes an upper triangular matrix U, and a vector b as input and returns the solution of the linear system U x = b. Use this function in the case when U is made of the numbers [(3,2,1),(0,5,4),(0,0,6)], and b = [1,1,−6]^T.
Write a function in Matlab that takes as input the number n and a symmetric tridiagonal...
Write a function in Matlab that takes as input the number n and a symmetric tridiagonal matrix given as two vectors: n×1 vector v representing the main diagonal and (n−1)×1 vector w representing the upper diagonal. Have this function output the Cholesky factor of the matrix as a vector for the main diagonal and a vector for the upper diagonal and output the number of flops and, separately, the number of square roots used as well. Use only basic programming....
Matlab Create/write a function that takes an input of x and y data, and a string...
Matlab Create/write a function that takes an input of x and y data, and a string (either linear? or quadratic), sets up a linear system of equations (Ax = b), and solves and plots the model.
Using Matlab, write a function that takes numeric data as its input argument and prints a...
Using Matlab, write a function that takes numeric data as its input argument and prints a message to the Command Window stating if the number is positive, or negative, or 0. This function should transfer an output value to the Workspace ONLY when the input value is negative. Please include a copiable code and the associated screenshots.
Write a C function called weighted_digit_sum that takes a single integer as input, and returns a...
Write a C function called weighted_digit_sum that takes a single integer as input, and returns a weighted sum of that numbers digits. The last digit of the number (the ones digit) has a weight of 1, so should be added to the sum "as is". The second from last digit (the tens digit) has a weight of 2, and so should be multiplied by 2 then added to the sum. The third from last digit should be multiplied by 1...
Write a function cube_all_lc(values) that takes as input a list of numbers called values, and that...
Write a function cube_all_lc(values) that takes as input a list of numbers called values, and that uses a list comprehension to create and return a list containing the cubes of the numbers in values (i.e., the numbers raised to the third power). This version of the function may not use recursion.
Write a python function which takes input matrix A and applies gaussian elimination with pivoting strategy...
Write a python function which takes input matrix A and applies gaussian elimination with pivoting strategy which returns P,Q (permutation matrices) L (lower triangular matrix with 1's on the diagonal) and U (upper triangular matrix) such that (P^t)(A)(Q)=LU is correct,
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT