Question

Given that x is a 200x4 matrix and u is a 1x4 matrix of all 1s....

Given that x is a 200x4 matrix and u is a 1x4 matrix of all 1s. I want to matrix multiply each row of x times u. To do this I want to transpose each row of x into a 4 by 1 matrix. multiply it by u and then set into a new matrix.

The new matrix should be 200 by 1. How can I do this in matlab?

Homework Answers

Answer #1

This is the whole process. Follow this to reach the final solution.

Read and understand the process and if you find difficulty comment it. I will provide the complete code too.

But try to figure it out by yourself.

To extract rows from a matrix:

A = [1 2 3; 4 5 6];

row1 = A(1,:)

row2 = A(2,:)

So first extract all rows and transpose them using:

The syntax is as follows:

B = A.'

B = transpose(A)

Then multiply these matrices with u to get the resultant value:

The syntax is as follows:

C = A*B

C = mtimes(A,B)

Then save these all values in a column vector to get the resultant 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
Finish the following M-file. Run your function on the same matrix A as given in the...
Finish the following M-file. Run your function on the same matrix A as given in the lab. % LU4 - The function in this M-file computes an LU factorization % of a 4 x 4 matrix under the assumption that elimination can be % performed without row exchanges. % Input: 4 x 4 matrix A; % Output: lower triangular matrix L and upper triangular matrix U. function [L,U] = LU4(A) L = eye(4); U = A; for j= ... for...
Evaluate general matrix function I want to evaluate this function exp(x) (2+sin(x)) at the matrix A...
Evaluate general matrix function I want to evaluate this function exp(x) (2+sin(x)) at the matrix A . How can I write it in Matlab? my tried is f= expm(A)*(2+funm(A,@sin)); but it is not correct
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) Generate a matrix from the matrix mat that is composed of row 2, row 1 and row 3 of mat Generate a matrix from the matrix mat that is composed on column 2 and 3 of mat Generate a matrix from the matrix mat that starts with column 2 and row 3 and contains all the elements till the end.
Given a matrix system AX = B as below, where A is a 4 x 4...
Given a matrix system AX = B as below, where A is a 4 x 4 matrix as given below A: 2          1          0          0 1          2          1          0 0          2          4          1 0          0          1          3 B: 0         -1 3 -1 Solve for all 4 X values using TDMA algorithm First identify the a, d, c and b values for each row, and then find P’s and Q’s and finally determine X’s.
Let A be a 2x2 matrix and suppose that det(A)=3. For each of the following row...
Let A be a 2x2 matrix and suppose that det(A)=3. For each of the following row operations, determine the value of det(B), where B is the matrix obtained by applying that row operation to A. a) Multiply row 1 by -4 b) Add 4 times row 2 to row 1 c) Interchange rows 2 and 1 Resulting values for det(B): a) det(B) = b) det(B) = c) det(B) =
I have a celll u(5,1) that looks like : u{​​​​​1,1}​​​​​=''ART1/TEACH'' u{​​​​​2,1}​​​​​=''H0ME/SHOW'' I want to remove the...
I have a celll u(5,1) that looks like : u{​​​​​1,1}​​​​​=''ART1/TEACH'' u{​​​​​2,1}​​​​​=''H0ME/SHOW'' I want to remove the first 5 characters from each of these strings so that in MATLAB: u{​​​​​1,1}​​​​​=''TEACH'' u{​​​​​2,1}​​​​​=''SHOW'' How can I do it?
Given the following utility function: U (X,Y) = 2X½ + Y and given that U =...
Given the following utility function: U (X,Y) = 2X½ + Y and given that U = 40 Part 1: Find Y1 for X = 4 Part 2: Find Y1 for X = 9 Part 3: Find Y1 for X = 16 Part 4: Find Y1 for X = 36 Part 5: Find Y1 for X = 49 Using graph paper construct the graph for indifference curve for U = 40 Given : Py = 20, Px = 5 and I...
Set theory proof: Rearrange: (A U B) X (C U D) to equal (A X C)...
Set theory proof: Rearrange: (A U B) X (C U D) to equal (A X C) U (B X D) I get stuck after the following steps: 1. (x,y) exist (A U B) X (C U D) 2. x exist (A U B) X y exist (C U D) 3. (x exist A OR x exist B) AND (y exist C OR y exist D) I know that somehow we can get to but I need it explained: 4. (x...
1. Ann’s utility function from consuming x and y is given by U(x, y) = x...
1. Ann’s utility function from consuming x and y is given by U(x, y) = x 1 4 y 1 4 . a) Write down the budget constraint and rationality condition. b) Find Ann’s demand curves of x and y. c) Now suppose Ann’s income is $100. The price of x is $1 and the price of $y is 2. What’s the optimal bundle? d) If the price of x increases to $2, and other things are the same as...
Let M be an n x n matrix with each entry equal to either 0 or...
Let M be an n x n matrix with each entry equal to either 0 or 1. Let mij denote the entry in row i and column j. A diagonal entry is one of the form mii for some i. Swapping rows i and j of the matrix M denotes the following action: we swap the values mik and mjk for k = 1,2, ... , n. Swapping two columns is defined analogously. We say that M is rearrangeable if...