Question

x = [1.3214; 1.8779; 2.1429; 2.2770; 2.4185; 3.5065; 4.7959; 5.3684; 5.9219; 6.6912; 6.9017; 7.1086; 8.1299; 8.2025;...

x = [1.3214; 1.8779; 2.1429; 2.2770; 2.4185; 3.5065; 4.7959; 5.3684; 5.9219; 6.6912; 6.9017; 7.1086; 8.1299; 8.2025; 8.3325; 8.6422; 9.1521; 9.2204; 9.2416; 9.4059; 9.6145; 9.6176; 9.6354; 9.6840; 9.7353]; y = [2.3779; 2.3929; 2.4543; 2.6263; 2.6952; 2.6936; 2.6415; 2.6140; 2.5823; 2.5790; 2.5700; 2.5694; 2.5677; 2.5415; 2.5366; 2.5098; 2.5003; 2.4974; 2.4638; 2.4508; 2.4472; 2.4379; 2.3999; 2.3603; 2.1660];

Write a function with the header

function [left, mid, right] = myNumericInt(x, y)

which takes two vectors of data (of equal length) and returns the integral using a Left Reimann sum approximation, Middle Reimann sum approximation, and Right Reimann sum approximation. The Middle Reimann sum should be found by estimating y values midway between x-values. Do not assume x is equally spaced. test

>>l,m,c] = myNumericInt(x,y)

l = 21.7187

m = 21.6771

c = 21.6355

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

=========================================

Save file as myNumericInt.m

=========================================

function [l,m,c] = myNumericInt(x,y)

l=0;
for i=1:length(x)-1
l=l+(x(i+1)-x(i))*y(i);
end
m=0.0;
for i=1:length(x)-1
m=m+(x(i+1)-x(i))*(y(i+1)+y(i))/2;
end
c=0.0;
for i=1:length(x)-1
c=c+(x(i+1)-x(i))*y(i+1);
end


end

============================================

Executable file

============================================

clear all
clc
x = [1.3214; 1.8779; 2.1429; 2.2770; 2.4185; 3.5065; 4.7959; 5.3684; 5.9219; 6.6912; 6.9017; 7.1086; 8.1299; 8.2025; 8.3325; 8.6422; 9.1521; 9.2204; 9.2416; 9.4059; 9.6145; 9.6176; 9.6354; 9.6840; 9.7353];
y = [2.3779; 2.3929; 2.4543; 2.6263; 2.6952; 2.6936; 2.6415; 2.6140; 2.5823; 2.5790; 2.5700; 2.5694; 2.5677; 2.5415; 2.5366; 2.5098; 2.5003; 2.4974; 2.4638; 2.4508; 2.4472; 2.4379; 2.3999; 2.3603; 2.1660];
[l,m,c] = myNumericInt(x,y)

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
x = [1.3214; 1.8779; 2.1429; 2.2770; 2.4185; 3.5065; 4.7959; 5.3684; 5.9219; 6.6912; 6.9017; 7.1086; 8.1299; 8.2025;...
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
  • 1. (25 pts) Let f(x) be a continuous function and suppose we are already given the Matlab function "f.", with header "function y fx)", that returns values of f(x) Given the following...

    1. (25 pts) Let f(x) be a continuous function and suppose we are already given the Matlab function "f.", with header "function y fx)", that returns values of f(x) Given the following header for a Matlab function: function [pN] falseposition(c,d,N) complete the function so that it outputs the approximation pN, of the method of false position, using initial guesses po c,pd. You may assume c<d and f(x) has different signs at c and d, however, make sure your program uses...

  • 1.1) Write a script in MATLAB that uses Reimann sum with 100 intervals (n=100) to calculate...

    1.1) Write a script in MATLAB that uses Reimann sum with 100 intervals (n=100) to calculate hydrostatic force of water on a triangular gate submerged under water (Figure 1). Give two estimates of this force (lower and upper bound for value of force). Hint: You may need to first find the hydrostatic force on the thin hashed slice by hand using the following information. Hydrostatic pressure P = pgz. p = 10003,= 9.81 m2/s. Note that h = 7-z and...

  • Random variables X and Y have joint probability mass function (PMF):

    Random variables \(X\) and \(Y\) have joint probability mass function (PMF):\(P_{X, Y}\left(x_{k}, y_{j}\right)=P\left(X=x_{k}, Y=y_{j}\right)= \begin{cases}\frac{1}{20}\left|x_{k}+y_{j}\right|, & x_{k}=-1,0,1 ; y_{j}=-3,0,3 \\ 0, & \text { otherwise }\end{cases}\)(a) Find \(F_{X, Y}(x, y)\), the joint cumulative distribution function (CDF) of \(X\) and \(Y\). A graphical representation is sufficient: probably the best way to do this is to draw the \(x-y\) plane and label different regions with the value of \(F_{X, Y}(x, y)\) in that region.(b) Let \(Z=X^{2}+Y^{2}\). Find the probability mass function (PMF)...

  • Please help with this MATLAB problem! I'm writing in MATLAB_R2018b if that makes a difference:) 7....

    Please help with this MATLAB problem! I'm writing in MATLAB_R2018b if that makes a difference:) 7. Write a Matlab function (HW07 07.m) that takes 4 arguments and returns two arrays. The arguments are the Xc and yc coordinates of the center of a circle, the radius r of the circle, and the number of points n on the circle. The function should create a list of n equally-spaced angle values ranging from 0 to 2n. Then, for each angle value,...

  • tl tt traRlo 2) The table below shows some values for a function questions. Use the...

    tl tt traRlo 2) The table below shows some values for a function questions. Use the values to answer the following 4 2 0 1 x 2.5 2.25 y-fx) 3, 4 1 a) (4 pts) Estimate f(x) dx by finding T, and illustrate your approximation on the graph of f shown at the right. y-Ax) 18 3.25 3 x 2.25 6.75 4-0 AX- b-a 2 L 2+ 3.2 = IS R, 3.2+ .s.2 = 10.5 T,18210.5 14.25 by finding M,...

  • The integral integral_3^9 x^2 dx can be calculated approximately by the left sum method (finding the...

    The integral integral_3^9 x^2 dx can be calculated approximately by the left sum method (finding the area of multiple rectangles whose top left corners lie on the curve). Figure 1 shows such an approximation with 4 rectangles. Write a MATLAB function to calculate the truncation error caused by the left sum method for integral_3^9 x^2 dx. Your function should meet the following requirements: It should be named NumericalInt It should have the number of rectangles as the sole input argument....

  • (Matlab) Suppose we have a function “hw5f.m” that takes as input x and outputs the value for a function f(x). Write a Matlab program that inputs: • interval [a, b]; • m, the number of data points wit...

    (Matlab) Suppose we have a function “hw5f.m” that takes as input x and outputs the value for a function f(x). Write a Matlab program that inputs: • interval [a, b]; • m, the number of data points with evenly spaced nodes from x1 = a to xm = b, and values from f(x); • location z satisfying x2 < z < xm−1, where h = (b − a)/(m − 1); and outputs the value of the interpolaton polynomial using only...

  • For starters, calculate the magnitude and direction of the electric field due only to charge q1...

    For starters, calculate the magnitude and direction of the electric field due only to charge q1 at this point. Down Up Left Right Incompatible units. No conversion found between "N" and the required units. Tries 0/10 Previous Tries Calculate the magnitude and direction of the electric field due only to charge q2 at this point. Down Up Left Right Tries 0/10 Calculate the magnitude and direction of the electric field due only to charge q3 at this point. Down Up...

  • Write MATLAB code g(x)=x+a*f(x) f(x)=(e^x)+(x^2)-x-4 function f(x) is stored in fogp1.m (c) (1) Create a file...

    Write MATLAB code g(x)=x+a*f(x) f(x)=(e^x)+(x^2)-x-4 function f(x) is stored in fogp1.m (c) (1) Create a file gopgi.m to calculate the function glir, a) (see Preparation, ex. 7c) function [y] =gopg1(x,a) % input: x, a % output: y y= .....; (2) Create a file sucsub1.m and write a program that calculates the solution using the method of successive substitution. Calculate the values of g(x, a) by making multiple calls to the function gopg1(x, a). Take xo = 1.3 as starting value...

  • sign Let f(x) 3x + 5, X, 2,2 - 3, X3-4,4 - 5, and Axu 1...

    sign Let f(x) 3x + 5, X, 2,2 - 3, X3-4,4 - 5, and Axu 1 mudy (m) Find (*)AX. radeb (b) The sum in part(a) approximates a definite integral using rectangles. The height of each rectangle is given by the value of the function at the left endpoint. Write the definite integral that the sum approximates. hapte (a) f(x)ax- Text 1 (Simplify your answer.)

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