Question

In: Computer Science

Use Matlab to introduce arow vector,f,and define it as a 1 by 4 vector showing values...

Use Matlab to introduce arow vector,f,and define it as a 1 by 4 vector showing values of 1, 2, 3and 4. Now try to build matrix D,

using the following 2 commands

a.D = [f ; A]

b.D= [f , A]

c.Which one can be built,and which one cannot be built? Explain your answer.

Matrix A, which is a 4by 4 matrix, (The first, second, third and fourth column values are:2,4,6,8and 1,3,5,7 and 8,6,4,2 and 7,5,3,1 , respectively.

Solutions

Expert Solution

Answer

Here is your answer, Here we can create a 1x4 vector with values 1 2 3 4, So, here we need to create a matrix called D, with concatenate one vector and one matrix called f and A. Actually in this above we need to show that which command is valid or not. So here is your matlab code,

using D=[f;A];

f=[1 2 3 4]; %created a 1x4 vector f
A=[2,4,6,8;1,3,5,7 ;8,6,4,2 ;7,5,3,1];%actually this is row values
A=A';%find transpose for make it is column value
D=[f;A];  %valid concatenation

%concatenate the  rows of the f with rows of A , dimension should be equal, columns number should be equal

ouput

using D=[f,A];

f=[1 2 3 4]; %created a 1x4 vector f
A=[2,4,6,8;1,3,5,7 ;8,6,4,2 ;7,5,3,1];%actually this is row values
A=A';%find transpose for make it is column value
D=[f;A];  %invalid concatenation in the case of f and A, dimension problem

%concatenate the  rows of the f with rows of A , dimension should be equal, columns number should be equal

it will produce the following error

This happend beacuse horzcat(), which trying horizontally concatenates two incompatible input matrices.

any doubt please comment

Thanks in advance


Related Solutions

Use MATLAB to create a vector x having six values between 0 and 10 (including the endpoints 0 and 10
Use MATLAB to create a vector x having six values between 0 and 10 (including the endpoints 0 and 10). Create an array A whose rst row contains the values 3x and whose second row contains the values 5x - 20.  
MATLAB. A three vector force system has forces as outlined, use a three element vector to...
MATLAB. A three vector force system has forces as outlined, use a three element vector to represent the x, y, and z terms respectively, F = [x_value, y_value, z_value]. Find the resultant force when: F1 has a magnitude of 120 N and is in the x-y plane, 35 degrees BELOW the positive x axis, F2 has a magnitude of 810 N and is in the x-z plane, 100 degrees ABOVE the positive x axis, and F3 has a magnitude of...
1) Use MATLAB to solve this differential equation. ??/?? = .25? (1 − ?/4 ) -...
1) Use MATLAB to solve this differential equation. ??/?? = .25? (1 − ?/4 ) - a 2) Use MATLAB to graph solution curves to this system with several different initial values. Be sure to show at least one solution curve for each of the scenarios found in ??/?? = .25? (1 − ?/4 ) - a ( let a = 0.16)
Matlab assignment. The objectives of this project are (1) to introduce the students to scripting applied...
Matlab assignment. The objectives of this project are (1) to introduce the students to scripting applied to solution of mechanical engineering problems and (2) to create a Matlab script that allows the computation of principal stresses and strains starting from a generic state of stress and that automates the drawing of 3D Mohr circles Assignment 1) Read from input a stress tensor (3D); 2) For any state of 3D stress compute the principal stress values (σ1, σ2, σ3) with σ1...
In MatLab use the linspace function and the element-wise exponentiation (power) operator to generate the vector...
In MatLab use the linspace function and the element-wise exponentiation (power) operator to generate the vector 1, 10, 100, 1000, 10000 Please give the answer in form of linspace( , , )
1.Define directional derivatives and the gradient vector in your own words and use material from the...
1.Define directional derivatives and the gradient vector in your own words and use material from the textbook and lectures as evidence. Please remember to cite your sources if you take information directly from a source. 2.In your own words, describe how gradient vectors could be applied to your future career or how it could be applied in the real-world. Use reputable resources including but note limited to, the textbook and lecture material, to support your answer. 3.In a sentence or...
In MatLab 1. Ask the user to enter a 1 x 5 vector of numbers. Determine...
In MatLab 1. Ask the user to enter a 1 x 5 vector of numbers. Determine the size of the user entry. 2. Ask the user to enter a 1 x 5 vector of numbers. Determine the size of the user entry. If the user enters a 5 x 1 vector, use a warning statement to inform the user of their error, and set the new input value to be the transpose of the user input value. If the user...
Create a vector of assumed probabilities and use it to obtain and display a vector of expected values, then check that the assumptions required for this test are satisfied.
  Goodness of Fit Microhabitat factors associated with forage and bed sites of barking deer in Hainan Island, China, were examined. The sample of 477 examined sites where the deer forage were categorized by habitat as follows: Habitat Woods Cultivated grassplots Deciduous forests Other Deer forage sites 15 16 50 386 In this region, woods make up 4.8% of the land, cultivated grassplots make up 14.7%, and deciduous forests make up 39.6%.Do these data provide convincing evidence that barking deer...
!!TRANSLATE TO MATLAB CODE!! INPUT: Function f, endpoint values a, b, tolerance TOL, maximum iterations NMAX...
!!TRANSLATE TO MATLAB CODE!! INPUT: Function f, endpoint values a, b, tolerance TOL, maximum iterations NMAX CONDITIONS: a < b, either f(a) < 0 and f(b) > 0 or f(a) > 0 and f(b) < 0 OUTPUT: value which differs from a root of f(x) = 0 by less than TOL N ← 1 while N ≤ NMAX do // limit iterations to prevent infinite loop c ← (a + b)/2 // new midpoint if f(c) = 0 or (b...
1. Find the probabilities f(0), f(1), f(2), f(3), and f(4) of a binomial distribution. Keep 4...
1. Find the probabilities f(0), f(1), f(2), f(3), and f(4) of a binomial distribution. Keep 4 decimal places in your answer. Use n=4 and p=0.15. 2. Keep 4 decimal places in your answer. About 75% of dog owners buy holiday presents for their dogs. Suppose n=4 dog owners are randomly selected. 2. Find the probability that a. at least one buys their dog holiday presents b. three or more buy their dog holiday presents c. at most three buy their...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT