Question

Write a MATLAB program to accomplish the following: Create a variable x by assigning it the...

Write a MATLAB program to accomplish the following: Create a variable x by assigning it the value 5. Then, subtract 8 from the square of x and assign the result to a second variable y. Next, create a vector z containing as values all the positive prime integers greater than or equal to 2 and less than 20. Multiply z by two and subtract y, and assign the result to w. ONLY display the value for w in the Command Window. DO NOT show any other values.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Breakpoints Run Run and Advance Run and Time ndent Advance EDIT MATLAB Production Server R2015a bin Editor-G: TLAB\Untitled2.?In the above MATLAB program we have created a variable x and assigned it a value of 5. Then y is assigned a value of 8 subtracted from square of x.

Later we created a row vector z containing all the positive prime integers greater than or equal to 2 and less than 20.

Then each element of z is multiplied by 2 and the value of y is subtracted from it and is assigned to w.

?Then by running the program w is displayed in the command prompt.

Add a comment
Know the answer?
Add Answer to:
Write a MATLAB program to accomplish the following: Create a variable x by assigning it the...
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
  • MATLAB Onramp ASSIGNMENT: 2. Create a 1x15 (1 row, 10 columns) vector of random numbers (use...

    MATLAB Onramp ASSIGNMENT: 2. Create a 1x15 (1 row, 10 columns) vector of random numbers (use randn command “x = randn(1,10)). And do the following: a.Test vector x for elements that are less than 0.2. Assign the output to a variable named y. b.Create a variable z that contains the elements in x that are greater than 0.2. c. Modify vector x such that any value in it less than 0.2 is replaced by value 0.

  • 3. Create a script. Save your script to your desktop. Complete the following: a) Write your name and section number on separate lines; use separate comments to accomplish this 1.2 2.3 b) Define a var...

    3. Create a script. Save your script to your desktop. Complete the following: a) Write your name and section number on separate lines; use separate comments to accomplish this 1.2 2.3 b) Define a variable -3.9and a variabley 7.5storing the results as variables x and y respectively c) Add π to each element of x and store the result as the variable x; add e to each element of y and store the new result as the variable y. Do...

  • Write a single C statement to accomplish each of the following tasks: Assign the sum of...

    Write a single C statement to accomplish each of the following tasks: Assign the sum of x and y to z and decrement the value of y by 1 after the calculation. Multiply num by 3 using the *= operator. Increment variable x by 1, then subtract it from variable value. Add variable x to variable total, then increment x by 1.

  • MATLAB ASSIGMENT 1. A. Create a function called ch16initials3 Input: row vector of 101 values (Note:...

    MATLAB ASSIGMENT 1. A. Create a function called ch16initials3 Input: row vector of 101 values (Note: input values are specified in the function call) Output: calculated maximum value Create a row vector A of values from 50 down to 0, with an increment of 0.5 Multiply the elements of A and the square of the elements of the input vector Store the results in B Find the maximum value of B and store it in C – this is the...

  • Write a single C++ statements to accomplish each of the following tasks: In one statement, assign...

    Write a single C++ statements to accomplish each of the following tasks: In one statement, assign the sum of the current value of x and y to z and postincrement the value of x. Determine whether the value of the variable count is greater than 10. If it is, print “Count is greater than 10.”. Pre-decrement the variable of x by 1, then subtract it from the variable total. Multiply variable power by x and assign the result to power.  ...

  • MATLAB Define the following computer programming terms and give an example of each. MATLAB example Sequence...

    MATLAB Define the following computer programming terms and give an example of each. MATLAB example Sequence Selection structure- Repetition structure - Relational operators (True = 1, False = 0) Logical operators (True = 1, False =0) And Or Less than Less than or equal to Greater than Greater than or equal to Equal to Not equal to Not ans ans Type the following relational operator commands into MATLAB in the command window one at a time. Write the results to...

  • Using Matlab; Please show written program to execute and instructions to create plot: 1. Create a...

    Using Matlab; Please show written program to execute and instructions to create plot: 1. Create a vector of x values from 0 to 20 pi, with an increment of pi/100. y=x sin (x) and z= x cos (x) a) create a figure window with two subplots. In first subplot create an x versus y plot and in the second subplot create an y versus z plot. b) create a polar plot of x and y. Add title and labels to...

  • Create a MATLAB function to perform Lagrange Interpolation. Your function will be used as illustrated below:...

    Create a MATLAB function to perform Lagrange Interpolation. Your function will be used as illustrated below: >> ya = Lagrange(x, y, a) where "x" is a vector of ? independent data values, "y" is a vector of ? dependent function values corresponding to "x", "a" is an arbitrary value of "x" for which you want to know the Westimate of "y", and "ya" is the estimate of the function at x=a. Print an error message and exit the function if...

  • MATLAB Any guidance is appreciated! Use meshgrid() function to create 2D grid coordinates with x- and...

    MATLAB Any guidance is appreciated! Use meshgrid() function to create 2D grid coordinates with x- and y- coordinates both from -12 to +12 in the increment 1/32. B) Calculate the function z shown below at every (x, y) point and store the result in a 2D array z Z = sin(squareroot x^2 + y^2)/ squareroot x^2 + y^2 c) Find the maximum value in array z and its corresponding index. The array may have more than one maximum points with...

  • Please show matlab editor and command window B. (4 pts) Use the : operator to create...

    Please show matlab editor and command window B. (4 pts) Use the : operator to create the vectors x [2.5,1.50.5,-0.5,-1.51 and y [0.4,0.8,1.2,1.6,2], then use them in the following expression to compute vector z using element-by-element calculations C. (8 pts) A 70 lb bag of rice is being pulled by applying a force F at an angle θ as shown. The force required to drag the bag is given by: θ μ sin θ + cos θ Where u-0.35 is...

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