Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask MATLAB Expert

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?

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M92769807

Have any Question?


Related Questions in MATLAB

Assignmentafter the success of your robo-advice venture you

Assignment After the success of your robo-advice venture you decide to explore alternative sources of profitability for your company. You realize that Australian investors are often forced to chose between expensive acti ...

Assignment -data is given on which want to do computational

Assignment - Data is given on which want to do computational production planning using Metaheuristic MATLAB Programming: 1) Ant Colony Algorithm on both Partial and Total Flexible Problem. 2) Bee Algorithm on both Partia ...

Assignment details -need to write a code for connecting

Assignment Details - Need to write a code for connecting segments (Lines) a special case of TSP. The problem is to connect lines in 2d/ 3d space with path obstructions. Can you help me write the code for this? Hope you m ...

Discrete optimisation- solve the following two problems

Discrete Optimisation - Solve the following two problems with both exhaustive enumeration and branch and bound - Problem 1 is a mixed integer linear optimisation problem (the problem has both discrete and continuous vari ...

Question a safe prime is a prime number that can be written

Question : A safe prime is a prime number that can be written in the form 2p + 1 where p is also a prime number. Write a MATLAB script file that finds and displays all safe primes between 1 and 1000.

Assignmentq1 find the laplace transforms of the following

Assignment Q.1 Find the Laplace transforms of the following functions: (a) t 2 + at + b and (b) sin(2nΠt/T) Q.2 Find f (t) for the following F(s) = α[ f (t)]. (i) 5/(s + 3), (ii) 1/s 2 + 25, (iii) 1/s(s+1) Q.3 Find the L ...

Recitation problems -1 determine the highest real root of

Recitation Problems - 1. Determine the highest real root of f(x) = 2x 3 - 11.7x 2 + 17.7x - 5 using the Newton-Raphson method with at least four iterations. Start with an initial guess of x 0 = 3. 2. Determine the real r ...

Lab assignment - matlab matrix relationallogical operators

Lab Assignment - MATLAB Matrix, Relational/Logical Operators and Plotting This laboratory exercise/assignment will involve you 1) practicing multiplication operators in MATLAB; 2) practicing relational and logical operat ...

Assignment -we have daily gridded rainfall data of 40 years

Assignment - We have daily gridded rainfall data of 40 years and structure of the dataset is like below; Lat = [6.5:0.25:38.5]; Lon = [66.5:0.25:100]; Rainfall (135x129x365x40) (Lon, Lat, days, years). Now, we looking fo ...

Suppose that you have used some concept learning algorithm

Suppose that you have used some concept learning algorithm to learn a hypothesis h1 from some training data. You are interested in knowing the accuracy that the hypothesis can be expected to achieve on the underlying pop ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As