Question
Use Matlab

Q1) Given: x [1,3,5,7,9; 1,4,7,10,13] Use one for loop to create the matrix y of dimension 5x2, using the index to program the address and the value of each element of y and y x Q2) Given: x [2,3,4,5 3,4,5,6] Use two for loops to create the matrix of dimension 4x2 Q3)Use a while statement to determine when the sum of the numbers in the series 1,2,3,4m is greater than 55. 0 in A.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Here we can see that difference between each element of first row and second row of matrix x is getting incremented. So, we can implement our code as follows:

x=[1,3,5,7,9];
y=zeros(5,2);
y(:,1)=x;
for i=0:4
y(i+1,2)=x(i+1)+i;
end
y

output:

y =

    1    1
    3    4
    5    7
    7   10
    9   13

2.

A=[2,3,4,5;3,4,5,6];
B=zeros(4,2);
[row col] = size(A);
for m=1:row
for n=1:col
B(n,m)=A(m,n);
end
end
B

output:

B =

   2   3
   3   4
   4   5
   5   6

3.

i=1;
sum=0;
while(sum<=55)
sum=sum+i;
i++;
end
i

This indicates that sum of numbers is greater than 55 after the result i.e. i in the code.

output:

i = 12

4.

A = [2,9,4,5,9,7,8,6];
row = size(A);
for i=1:row
if(A(i)<4)
A(i)=0;
end
end
A

The result would be : A = [0,9,4,5,9,7,8,6]

Add a comment
Know the answer?
Add Answer to:
Use Matlab Given: x = [13, 5, 7, 9, 1, 4, 7, 10, 13] Use one...
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
  • answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for...

    answer 4, 5, 6, 7 using matlab Homework 10 1. Write the correct first-line syntax for a user defined function that is named Feynman and has input variables q and e, and outputs L and M. (Comment out of this line). 2. Using zeros, ones, and eye commands write the one line syntax to create the following matrix: 00000 01100 01010 01001 3. Write the syntax for the user defined function that calculates the surface area and volume of a...

  • Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5...

    Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5 3 4 1 3 2 10 12 4 2 7 9 2 4 51 use a for loop to (a) Add up the values of all elements in x (b) Compute the cumulative sum, y, of elements in x You can check your results using the built-in functions sum and cumsum. Q.5 What is the value of the sum of elements in vector x?...

  • In Matlab A= 3 -5 6 ( 15 7 9 13 5 -4 12 10 2...

    In Matlab A= 3 -5 6 ( 15 7 9 13 5 -4 12 10 2 8 11 4 1 For the matrix A in problem-2, use MATLAB to carry out the following instructions a. Find the maximum and minimum values in each column. b. Find the maximum and minimum values in each row. c. Sort each column in ascending order and store the result in an array P. d. Sort each row in descending order and store the result...

  • solve these questions by Matlab 10 9:17 X ull ** - STC Report Lab - للقراءة...

    solve these questions by Matlab 10 9:17 X ull ** - STC Report Lab - للقراءة فقط (1) 28 Hoď → 7 سجل دخولك لتحرير الملف وحفظ التغييرات ا... Problems Problem 1: The following polynomials are given: Py(x) = x + 2x4 - 3x + 7x2 - 8x + 7 Polx) = x + 3x - 5x2 + 9x + 11 P3(x) = x - 2x - 3x +9 P4(x)=x2-5x + 13 Ps(x) = x + 5 Use MATLAB functions...

  • using matlab Create the following matrix B. [18 17 16 15 14 13] 12 11 10...

    using matlab Create the following matrix B. [18 17 16 15 14 13] 12 11 10 9 8 7 6 5 4 3 2 1 Use the matrix B to: (a) Create a six-element column vector named va that contains the elements of the second and fifth columns of B. (6) Create a seven-element column vector named vb that contains elements 3 through 6 of the third row of B and the elements of the second column of B. Create...

  • 1. 2. 3. 4. 5. Given that B = {[1 7 3], [ – 2 –7...

    1. 2. 3. 4. 5. Given that B = {[1 7 3], [ – 2 –7 – 3), [6 23 10]} is a basis of R' and C = {[1 0 0], [-4 1 -2], [-2 1 - 1]} is another basis for R! find the transition matrix that converts coordinates with respect to base B to coordinates with respect to base C. Preview Find a single matrix for the transformation that is equivalent to doing the following four transformations...

  • PLEASE USE MATLAB Create a single MatLab script that On a single line (Line 1), defines...

    PLEASE USE MATLAB Create a single MatLab script that On a single line (Line 1), defines matrix A such that A = 1 2 4. 5 7 8 Suppress the echo of A. On a single line (Line 2), use the size function to echo the size of A. On a single line (Line 3), use the length function to echo the length of the entire first row of A. On a single line (Line 4), use linear index notation...

  • Problem 1: Use MATLAB to create a script file and publish a pdf file for the...

    Problem 1: Use MATLAB to create a script file and publish a pdf file for the problem: Given that MX = Y, for the following matrices determine X using both matrix inversion and Gaussian elimination methods 7 -2 4.67 5 7 6.5 -8 13 Y = 13 Display results in short engineering format. Submit the published pdf file. Problem 2: Use MATLAB to create a script file and publish a pdf file for the problem: Given that MX = Y,...

  • Compute the following problems using Math Lab.   Instructions: Answer All Questions using MATLAB commands. Question 1....

    Compute the following problems using Math Lab.   Instructions: Answer All Questions using MATLAB commands. Question 1. Create a vector of the even whole numbers between 31 and 75. Question 2. Let x [2516] a. Add 16 to each element b. Add 3 to just the odd-index elcments c. Compute the square root of each element d. Compute the square of each element Question 3. Let x 13 268T and y [4 1 3 5] (NB. x and y should be...

  • 1. For a matrix 5 9 6 (1) Use Matlab command to calculate the transpose matrix...

    1. For a matrix 5 9 6 (1) Use Matlab command to calculate the transpose matrix (2) Use Matlab to calculate the determinant of the matrix (3) Justify if the matrix has the inverse matrix and use Matlab to calculate the inverse Matrix (4) Use Matlab to calculate the eignvalues and eignvectors of the Matrix

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
ADVERTISEMENT