Evaluate the function at a range of x values

Assignment Help MATLAB Programming
Reference no: EM131258659

Introduction to Programming in MATLAB Assignment

1. Revisiting MATLAB matrices and built-in functions.

a) Factor the following polynomials using MATLAB:

i. x2 + 18x + 81

ii. x2 + 11x + 24

iii. x2 - 10x + 9

iv. x3 - 4x2 + 4x - 16

v. 2x2 - 16x - 40

b) Multiply the following vectors using "dot" multiplication. What does this type of operation do in contrast to traditional matrix multiplication?

i. [5,6,9]' with [10,10,10]'

ii. [1,1,1]' with [2,5,1]'

iii.
653_Matrix.jpg

2. Plotting in MATLAB.

a) Consider the following function:

y = f (x) = sin(x) + x2 + 62

Create vectors from -10 to 10 with the following step-sizes:

i. 5

ii. 1

iii. 0.1

iv. 0.001

v. 0.00001

plot the results on the same graph. Add axis labels, title and legend.

b) Create multiple figures, plotting all data from part (a). Create new titles, as necessary. Change the line styles to the following:

i. red, black, green, cyan, magenta - grid on

ii. black diamonds, red circles, blue x's, dashed magenta, dotted green - grid off

iii. black asterisks, red squares, dotted red, blue dashes, magenta squares - grid on

c) Consider the following functions:

Y1 = 6sin xi + cos 2x1

y2 = 12sin 2x1 + cos 4x1

define x1 from 0 to 2π with the following number of elements:

i. 10 elements

ii. 100 elements

iii. 1000 elements

 

iv. 10000 elements

 

for each (i) - (iv) above, evaluate y1 and y2. Create a single figure window showing the progression of resolution as elements are added to x1. Each plot should have a legend, appropriate title and axis label and include the results from both y1 and y2. (hint: use subplots).

 

d) Consider the following two functions:

 

f1 (x) = 3x3 + 3x + 87

 

f2 (x) = (x/2) + 3 + √64x

 

evaluate these functions from x = 0 to 100 in a step size that gives acceptable resolution (use your judgment!). Plot the results on the same figure. What is one problem with the figure generated? Find another MATLAB function that will fix this plotting issue and regenerate your plot. Add appropriate axis labels, legends, titles, etc.

 

e) Consider the data set given by the x and y vectors below:

 

y= [3, 15, 26, 35, 41, 52, 60, 77, 84, 90, 95, 100]

 

x= [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]

 

Plot this data using a semi-log scale, creating a plot that has a natural logararithmic y-axis. (hint: semilogy()).

 

3. Working with MATLAB function files.

 

a) Write a function file, that accepts values of x as inputs and outputs the value of y when the input is passed through the following function:

 

y = e√56x+3.21 + 4x + 0.2x2

 

evaluate the function at a range of x values from 0 to 1 with 143 elements.

 

b) Consider the functions below, both of which are dependent on a single input, x. Create a function file that will return the value of both calculations when provided a value (or series of values) of x. Evaluate your functions for x values of 1,2,3 and 4 as well as the vector from 0 to 10 with 1000 elements. Plot your results, adding figure labeling, legends, etc. as necessary. You should present two plots, each with two lines.

 

Y1 = x + 5

 

Y2 = e3x + sin (x)

 

c) Modify your function from 3(b) so that, after evaluating the value of yi for a given value of x, an intermediate calculation is performed which divides x by 10 before it is used in evaluating y2. Evaluate your function at the same points as 3(b) and compare the results.

 

d) Create a function file to evaluate the value of sin x accurate to 9 Taylor series terms.

 

Recall, the Taylor series for sin x is given by:

 

sin x ≈ x - x3/3! + x5/5! - x7/7! + x9/9! - x11/11! + x13/13! - x15/15! + x17/17!

 

* NOTE: There are multiple ways to do this problem. Think it through before you code!

 

Evaluate your function at various points on the domain [0, 2π]. (at least 3)

 

e) Create a function file to evaluate the multivariable function f(x,y,z) below.

 

 

f (x, y, z) = (x2y/X2 +y2) + Z3x

 

evaluate the function at the following points: (1,1,1), (1,0,1), (e3,1,5).

 

f) Consider an object, whose position along the x-axis is given by:

 

x = -½g t2

 

create a function that has time as an input and returns the position (along x) of the object, the x-axis velocity at time "t" and the acceleration of the object. (hint: think about how many outputs the function must have and how to relate the velocity and acceleration to the given function). Plot the above quantities from t = 0 to 10 with 100 elements. You should use subplot where, from top to bottom the plots should be in the order: position, velocity, acceleration. All plots should be labeled appropriately.

 

Create anonymous functions in your script file to define and evaluate the following functions:

 

i. f (x) = x2 + 4x + 6 for x = 1,5,10

 

ii. f (x, y) = xy + x2 y - y2 - 1) for (1,4), (-1,-4), (4,1)

 

iii. f (x, y) = sin x + cos 2y for (0,0), (√2/2, √2/2)

 

 

iv. f (x, y) = exy + In 4x - log10 5xy for (1,1), (6,4), (2,10)

Reference no: EM131258659

Questions Cloud

How specifically you plan to either leverage insight present : From the first e-Activity, share an insight that you learned about yourself related to management readiness. Indicate how specifically you plan to either leverage the insight at present or act on it in the future. Provide support for your rational..
Identify some of the problems faced by a company : Using sources from the Internet, identify some of the problems faced by a company of your choosing as it moves toward, or operates as, a virtual organization.
What is the equilibrium concentration of the chromium : Chromium contamination is a problem at a number of hazardous-waste sites. At one site local concentrations of chromium reached 60,000 mg chro-mium/kg soil and 19,000 mg/L chromium in the water.
What is bakers percent of assets committed to inventory : What is Baker's inventory turnover? - What is Baker's percent of assets committed to inventory? -  How does Baker's performance compare to the industry leaders?
Evaluate the function at a range of x values : Write a function file, that accepts values of x as inputs and outputs the value of y when the input is passed through the following function. Evaluate the function at a range of x values from 0 to 1 with 143 elements.
Propose two applications of knowledge that you have learned : Rate the three (3) most important concepts that you learned in this course in order of importance (one (1) being the most important; three (3), the least). Provide a rationale for your ratings. Propose two (2) applications of knowledge that you ha..
Maximize total returns on loans : To maximize total returns on loans made by the bank, P, state the objective function using A and B to represent the two companies, respectively.
What was organic grocers inventory turnover : What was Organic Grocers' inventory turnover, and how does that performance compare with that of the industry?
Calculate the jacobian matrix and linearize : Find the critical points of the system and describe them in biological terms. Calculate the Jacobian matrix and linearize around each critical point. Classify the critical points and sketch the vector field by hand.

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Generate by means data.m an array

Generate by measdata.m an array A withsize (365,24), containing temperature measurements for an entire year [1 January,..., 31 December], 24 hours a day [00.00h,...,23.00h].

  Determine the optimal linear predictor

Determine the optimal linear predictor for a given order N and DPCM simulation and write a graphical user interface that has least the following functions

  Compare filter with that given by matlab function bilinear

Compare your filter with that given by the Matlab function ‘bilinear' for the same conditions. Manually design a second order digital filter, with the damping ratio given in the table.

  Write commands to solve the system of equations

Write MATLAB commands to solve the system of equations. 7x-14y=95 -5x+9z=-50 -5x+15z=145

  Write matlab scripts

Write MATLAB scripts for to accept two numbers from the user; Display all prime numbers between these two numbers.

  Develop a simulation program

Develop a simulation program

  Matlab code to solve for temperature and pressure variation

Write down the MATLAB code to solve for temperature and pressure variation throughout the expansion process and to evaluate work and heat produced in processes for variable values of n.

  Function that will use the secant method to try to find

Create a function that will use the Secant method to try to find a root. (Hint modify the posted version of False Position.) Because this method may diverge

  Write a matlab function that takes in one argument

Write a MatLab function that takes in one argument, a vector or 2-D matrix and returns a single value, the highest value in the vector or matrix. Use nested for loops to accomplish this task. Assume that all of the values in the vector or matrix are ..

  Determine the true displacements using the true weights

Matlab Three masses are attached to spring, k1 = 30 N/m, k2 = 25N/m, k3 = 20N/m, and k4 = 15N/m, as shown. Initially the masses are positioned such that the springs are in their natural length (not stretched or compressed); then the masses are slo..

  Write a matlab script m-file to play a guessing game the

write a matlab script m-file to play a guessing game. the user will try to guess a number between 1 and 100. your

  Which degree do you think best represents the data

Write a Matlab script to try fitting a 1st, 2nd, and 3rd degree polynomial to the dataset described by volume of water vs. volume of ice. Use subplot to draw all three

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd