Prepare a Matlab code to calculates the function

Assignment Help MATLAB Programming
Reference no: EM131931149

Problem 1 - Write a Matlab script that evaluates the following piecewise function for any user inputs x1 and x2.

2493_figure.png

Test you code using the following values: f(-2, 3) = 7, f (2, -3) = 10, f(2, 3) = 11, f (-2, -3) = 13.

Problem 2 - Prepare a Matlab code to calculates the function

y(x) = In 1/(x2-25)

for any legal user-input x. If the inserted value of x is illegal, report that to the user by printing an error message on the Matlab command window. Note that in the above equation, In is the natural algorithm to the base e, the Matlab function for this mathematical function is log.

Problem 3 - Write a script file that creates a plot of the function shown below. Plot the function from x = -2 to x = 4 (use an increment of 0.01 for your x-vector). Label the axes as "X-Axis" and Y-Axis" respectively, and turn the grid on.

Hint: Be sure to use your "." operator!

f(x) = 3.5-0.5x cos(6x)

Problem 4 - An experiment is performed to measure the intensity of a source of light over a distance. The experiment yielded the following data:

Distance (cm)

10

12

14

16

18

20

22

"x" values

Intensity (lux)

950

640

460

340

250

180

140

"y" values

Write a script file that plots both the experimental data above and the theoretical equation shown below.

y = 95000/x2

For the variables:

  • Create a vector containing experimental distance [Use xe as the variable name].
  • Create a vector containing experimental intensity [Use ye as the variable name).
  • Create a vector containing theoretical distance [Use xt as the variable name) - This vector should contain values from x = 10 to x = 22 at an increment of 0.05.
  • Create a vector containing theoretical intensity [Use yt as the variable name). Be sure to use your "." operator.

For the plot:

Plot the experimental data first, using a red dashed line with circle markers. Use a line width of 1.0 pixels and a marker size of 8.0 pixels.

Title the chart as "Light Intensity as a Function of Distance." Label the x-axis "Distance (cm)" and the y-axis "Intensity (lux)."

Plot such that the x-axis is bounded from 8 to 24 and the y-axis is bounded from 0 to 1200. Also, turn the grid on.

Plot the theoretical model data next, using a line width of 1.0 pixels.

Last, create a legend, labeling the data sets "Experimental" and "Theoretical," respectively.

Problem 5 - For the experimental data points below, write a script that will fit two polynomials (a line and a parabola) to see which predicts the data best and p of the results.

X-Values

0.0

0.5

1.0

1.5

2.0

2.5

3.0

3.5

4.0

4.5

5.0

Y-Values

6.00

4.83

3.70

3.15

2.41

1.83

1.49

1.21

0.96

0.73

0.64

For the variables:

  • Create a vector containing experimental X-Values [Use x as the variable name]
  • Create a vector containing experimental Y-Values [Use y as the variable name]
  • Use polyfit( ) to fit a line to the data [Use p1 as the variable name]
  • Use polyval( ) to compute corresponding y-values for x [Use y1 as the variable name]
  • Use polyfit( ) to fit a parabola to the data [Use p2 as the variable name]
  • Use polyval( ) to compute corresponding y-values for x (Use y2 as the variable name]

For the plot:

  • Plot the experimental data first, using circle markers only and no other formatting. To do this, just specify ' o
  • Label the axes as "X-Axis" and Y-Axis" respectively, and turn the grid on."
  • Note that you don't need to use the hold command. Instead, just plot all of the data sets with a single plot ( ) command.

Finally, using the more accurate polynomial, use polyval ( ) to determine the predicted value at x = 4.25. Assign this to variable c at the end of your script.

Please do it and explain how you did it?

Reference no: EM131931149

Questions Cloud

Which country has an absolute advantage in radios : Which country has an absolute advantage in Radios? In Corn? Which country has a comparative advantage in Radios? In Corn?
What portion of the claim will the insurance company pay : If you have a $160 deductible for collision and full coverage for comprehensive, what portion of the claim will the insurance company pay?
Return on investments should your client earn : You are considering an investment in a security with a beta of 1.4. Which of the following return on investments (ROIs) should your client earn?
Misleading indicator of development : People often argue that the level and growth rate of real GDP per capita can be a misleading indicator of development.
Prepare a Matlab code to calculates the function : Prepare a Matlab code to calculates the function. If the inserted value of x is illegal, report that to the user by printing an error message on Matlab command
How the endogenous growth theory : Contrast how the Endogenous growth theory differs from the Harrod-Domar growth model in the role that population growth plays in per capita income.
Discuss the link between early menarche and obesity : Discuss the link between early menarche and obesity; also, examine how the nurse would evaluate the BMI when considering pubertal development.
What would be cost of new equity : New stock can be sold to the public at the current price, but a flotation cost of 10% would be incurred. What would be the cost of new equity?
What were the major goals of the deregulation : Pick an industry that has been deregulated in the US in the past 20 years. What were the major goals of the deregulation?

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Finite difference method

Use the finite difference method to calculate the temperature at the point specified since it is easier.

  Determine the necessary shell temperature

In a shell-and-tube heat exchanger, one fluid passes through a central tube while another fluid flows through an outer shell in the opposite direction. The purpose is to heat the fluid passing through the central tube.

  Find the integral of a function at an arbitrary location

Write a Matlab function to perform numerical integration of a set of evenly spaced data points using the trapezoidal rule

  Compute the speed of single-stage planetary gear train

Write a MATLAB function [speed] = planetary (N, emesh, first, last, arm) that computes the speed of a given link in a single-stage planetary gear train.

  Calculate and plot the error in the numerical derivative

Write a program to calculate and plot the error in the numerical estimate of the derivative.

  Create the graph using matlab functions

Create the graph, which contains a piecewise function where a line exists in the first interval, a parabola in the second interval, and the sine function in the third interval.

  Develop a simulation program

Develop a simulation program

  Create a vector in matlab

Create a three dimensional diagram of function.

  Open a named pipe and to read data from the pipe

Open a named pipe and to read data from the pipe in matlab

  Write the commands that will create the matrix

Write the commands that will create the matrix.

  Lagrange interpolating polynomial of degree

Lagrange interpolating polynomial of degree

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