I need to calculate each slice differently if its height was above or below 25.
ID: 3109815 • Letter: I
Question
I need to calculate each slice differently if its height was above or below 25. for example, in slice 3 there will be two different areas area above 25 and area under 25.is there any code that could help me find the area, as I don't have the x points for some of the slice when its height is 25.
these are the point for the curve.
x= [-21.4, 0, 21.4, 42.8, 64.2, 85.6, 107, 128.4, 150, 171.4];
y= [0, -2.89, -2.89, 0, 5.89, 15.24, 28.72, 47.92, 76.84, 121.31];
i need a MATLAB code
160 140 120 100 80 60 40 20 20 50 50 100 150 200Explanation / Answer
>> n = 9; % number of small trapeziums formed after splitting
a = -21.4; % starting point or lower limit of the area
b = 171.4; % end point or upper limit of the area
sum = 0.0; % to find the sum
dx = (b-a)/(n-1); % to find step size or height of trapezium
% Generating the samples
for i = 1:n
x(i) = a + (i-1)*dx;
end
% to generate the value of function at different values of x or sample
for i = 1:n
y(i) = 9E-10x(i).^5 - 2E-07x(i).^4+1E-05x(i).^3+0.003x(i).^2-0.074x(i)-2.825;
end
% computation of area by using the technique of trapezium method
for i = 1:n
if ( i == 1 || i == n) % for finding the sum of fist and last ordinate
sum = sum + y(i)./2;
else
sum = sum + y(i); % for calculating the sum of other ordinates
end
end
area = sum * dx; % defining the area
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.