Question

In Matlab write a script that does the following. 1. Creates a row vector v =...

In Matlab write a script that does the following. 1. Creates a row vector v = [3, 6, 9, 9, 15], and then manipulates v to create each of the following vectors (and then displays the result of each): (a) a = [9, 36, 81, 81, 225] (b) b = [ 1 3 , 1 6 , 1 9 , 1 9 , 1 15 ] (c) c = [1, 2, 3, 3, 5] (d) d = [15, 9, 9, 6, 3] 2. Creates a vector w that contains values from zero to 10 (with a spacing of 2 in between values), and then multiplies the entire array by 3, then subtracts 10 from every element, and stores the result in a vector z (and displays vector z). 3. Creates the following arrays: A = 1 2 3 −2 0 1 0 7 2 B = 1 2 3 −6 10 1 2 0 5 C = 0 3 1 −2 0 1 D = 0 0 0 0 0 1 And then calculates each of the following (and displays the result): • The matrix product of A and B • The matrix product of B and A • The result of multiplying A and B element-by-element • The inverse of A • A single boolean (1 or 0), indicating whether or not A contains the number 7 • A single boolean (1 or 0), indicating whether or not D is ALL zeros • A single boolean (1 or 0), indicating whether or not A and C are equal • A single boolean (1 or 0), indicating whether or not A and B are equal • An ARRAY of booleans, indicating whether EACH ELEMENT of A matches the corresponding element of B • The sum of ALL of the elements in C

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%% as per HomeworkLib policy only 4 questions are to be answered

%%part1
v=[3,4,9,9,15];
%%part a
a=v.^2
b=v+10
c=v./3
d=fliplr(v)
%% part2
w=0:2:10
z=3.*w-10
%%part3
A=[1,2,3;-2,0,1;1,0,7];
B=[1,2,3;-6,10,1;2,0,5];
C=[0,3,1,-2,0,1];
D=[0,0,0,0,0,1];

%a
A*B
%b
B*A
%c
A.*B
%d
inv(A)

Add a comment
Know the answer?
Add Answer to:
In Matlab write a script that does the following. 1. Creates a row vector v =...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • TASK 1: [20] • Write a little program that creates a vector array of type doubles with 10 members (0…9) • Use a for loop to store the values i^2 in the vector for each index i • Also write code to display the content of the vector • The output shou

    TASK 1: [20] • Write a little program that creates a vector array of type doubles with 10 members (0…9) • Use a for loop to store the values i^2 in the vector for each index i • Also write code to display the content of the vector• The output should be: 0, 1, 4, 9, 16, 25, 36, 49, 64, 81 • Instead of using array access, try to use push_back, pop_back, etc. also, i.e. try being dynamic. TASK...

  • Assignment Input from the user 9, 64-bit, floating-point values as a 3x3, row-major, multi-dimensional array. This...

    Assignment Input from the user 9, 64-bit, floating-point values as a 3x3, row-major, multi-dimensional array. This will be the 3x3 matrix. Then, input 3, 64-bit, floating-point values. This will be a single-dimensional array and is the vector. Your program will simply ask the user to enter matrix values. Remember, there are 9 of these, but they need to be stored into a 3x3 multi-dimensional array (row-major). Then, your program will ask for the vector values, which will be stored into...

  • 1. What does the below C++ statement do? vector<double> myVec(20); Group of answer choices A.It creates...

    1. What does the below C++ statement do? vector<double> myVec(20); Group of answer choices A.It creates a vector object that can only store values of 10 or less. B.It creates a vector object with a starting size of 10. C.It creates a vector object and initializes the first element with the value 20. D.It creates a vector object with a starting size of 20. 2. A recursive function contains a call to itself, but is limited to 10 recursive calls...

  • on matlab (1) Matrices are entered row-wise. Row commas. Enter 1 2 3 (2) Element A,...

    on matlab (1) Matrices are entered row-wise. Row commas. Enter 1 2 3 (2) Element A, of matrix A is accesser (3) Correcting an entry is easy to (4) Any submatrix of Ais obtained by d row wise. Rows are separated by semicolons and columns are separated by spaces ner A l 23:45 6. B and hit the return/enter kry matrix A is accessed as A Enter and hit the returnerter key an entry is easy through indesine Enter 19...

  • Write PHP that does the following: Creates 4 variables, with values “My”, “Name”, “is”, “Bill”. Concatenates...

    Write PHP that does the following: Creates 4 variables, with values “My”, “Name”, “is”, “Bill”. Concatenates all 4 variables using the concatenation operator, while adding a space between each one and assigns the result of the concatenation into a 5th variable named $stringCatResult. Display the $stringCatResult value using an echo statement. Write PHP that does the following: Creates 2 variables, with values 12 and 3 Write five separate lines of code that performs an arithmetic operation on the 2 variables....

  • 1.Write a Java program that computes the average of the values of a row in a...

    1.Write a Java program that computes the average of the values of a row in a twodimensional array. You should create a method with the following header: public static double averageRow(double[][] array, int row) Write a test program that reads a matrix from the user and a row index to calculate the average on. Print the result. 2.A square matrix is said to be an upper triangular matrix if the value of the cell is 0 when row > column....

  • Question 1 a. Define the following matrices in a script file (M-file), ? = ( 8...

    Question 1 a. Define the following matrices in a script file (M-file), ? = ( 8 9 10 11; 23 9 16 15 ;11 12 3 6; 1 2 8 9 ) ? = ( 2 21 7 15; 12 4 8 22; 23 9 5 13; 23 4 21 22) ℎ = (4 9 12 15) b. Add suitable lines of codes to the M-file to do the following. Each of the following points should be coded in only...

  • Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as...

    Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as output, c, returns the number of zeros at the beginning of v (number of zero elements before any non-zero element). For example, for input (-5, 5, 11] the output would be 0. If the input is [0, 0, 3, 0, 0, 0], the output would be 2. If the input is [0, 0, 0, 0, 7, 4) the output would be 4. 5) Write...

  • matlab help Write a script to manipulate the array A = [2 1 4 3 6...

    matlab help Write a script to manipulate the array A = [2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19] to be in descending order without using the sort function. You must do everything using array manipulation in MATLAB (i.e. you cannot sort it by hand and then hardcode it, you cannot simply create the array 1:20, you cannot simply add .rej3mat(J-l 1],1,10) to A). Write a script that...

  • Write a program to find product of a row vector, U having dimension 1 x 2...

    Write a program to find product of a row vector, U having dimension 1 x 2 with a 2 x 2 matrix, A. The input to the program includes initialized row vector, U and matrix, A. The expected output is a transformed row vector. You can test your program using following example: A = 2 4 5 1 4 5 1 and U = [3 2] The result of product U.A is a transformed row vector: [16 14] Q2. Write...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT