First Derivative Central:
Write a user written function that expects as its input argument a vector of x values and a vector of corresponding y-values. The function must return a matrix with 2 columns. The first column contains ‘mid-point’ x-values. The second column must contain the centered difference approximations for the first derivative, dy/dx, at the step midpoints. In other words, the x values [(x2+ x1) / 2 , (x3+ x2) / 2,..., (xn+ xn-1) / 2] and corresponding first derivatives estimates should be returned.
Must be completed using loops, if/else statements and indexing in matlab. Cannot use matlab functions to solve for the derivatives. The x and y vector values are random and not given.
Mat lab Program:
clear
clc
% taking x and as a random vector
x=input('Enter the vector of x: ');
% use this as input [0 1 2 3 4 5 6 7 8 9 10];
y=input('Enter the vector of y: ');
% use this as input [0 1 4 9 16 25 36 49 64 81 100];
i=1;
if length(x)~=length(y)
error('Enter both the vectors of same length');
end
n=length(x);
X=zeros(n-1,1);
Y=zeros(n-1,1);
for i=1:n-1
% X is mean of the vector X
X(i)=(x(i)+x(i+1))/2;
% Y is central difference
Y(i)=((y(i+1)-y(i))/(x(i+1)-x(i)));
end
disp([X Y]);
Screenshot:

Save the above program and execute it.
Give the input.
Result:

Note: the function I used is x^2
So, the derivative is 2*x, and the answer is matching.
I hope this will help you, please give me thumbs-up.
First Derivative Central: Write a user written function that expects as its input argument a vector...
Using the definition, calculate the derivative of the function. Then find the values of the derivative as specified. f(x) = 3 + x2: f'(- 9), F 'O), f (9) Using the definition, calculate the derivative of the function. Then find the values of the derivative as specified. 4 96) = 3. g'(-2), g'(4), g(6) o't)= dx if y = 7x3 dy || s={3 - 4+, t= -6 s'(t)= 0 ne indig y=f(x)= 3 + 14-x, (x,y)= (0,5) The derivative of...
Please help me answer this question using matlab
Consider the function f(x) x3 2x4 on the interval [-2, 2] with h 0.25. Use the forward, backward, and centered finite difference approximations for the first and second derivatives so as to graphically illustrate which approximation is most accurate. Graph all three first-derivative finite difference approximations along with the theoretical, and do the same for the second derivative as well
Let f(x)=(x? + 1)^(2x – 1) is a polynomial function of fifth degree. Its second derivative is f"(x) = 4(x2 + 1)(2x – 1)+8x²(2x – 1)+ 16x(x? + 1) and third derivative is f"(x) = 24x(2x – 1) +24(x + 1) +48x2. True False dy Given the equation x3 + 3 xy + y2 = 4. We find dx 2 x' + y by implicit differentiation and is to be y' = x + y2 True False Let f(x)= x...
Write a user-defined MATLAB function for the following math function y(x). The input to the function is x and the output is y. y(x)=-(0.2*x^4)+((e^-0.5*x)*x^3)+7*x^2 Call the function to calculate y(x) over the interval -3 ≤ x ≤ 4 for each increment of 1. Display x and corresponding y(x) in a text file with labeled column headings. Use the type command to display the contents in the text file.
Matlab: Write a function called minimax that takes M, a matrix input argument and returns mmr, a row vector containing the absolute values of the difference between the maximum and minimum valued elements in each row. As a second output argument called mmm, it provides the difference between the maximum and minimum element in the entire matrix. See the code below for an example: >> A = randi(100,3,4) A = 66 94 75 18 4 68 40 71 85 76...
Calculate the Y values corresponding to the X values given below. Find the critical values for X for the given polynomial by finding the X values among those given where the first derivative, dv/dx- 0 and/orn X values where the second derivative, d-y/dx2-0. Be sure to find the sign (+ or-) of dv/dx and of d'y/dx2 at all X values. Using the first and second derivative tests with the information you have calculated, determine which X value(s) represent maximums (MAX),...
1)
a) Write MATLAB function that accepts a positive integer
parameter n and returns a vector containing the values of the
integral (A) for n= 1,2,3,..., n. The function must use the
relation (B) and the value of y(1). Your function must preallocate
the array that it returns. Use for loop when writing your code.
b) Write MATLAB script that uses your function to calculate the
values of the integral (A) using the recurrence relation (B), y(n)
for n=1,2,... 19...
Calculate the Y values corresponding to the X values given below. Find the critical values for X for the given polynomial by finding the X values among those given where the first derivative, dv/dx- 0 and/orn X values where the second derivative, d-y/dx2-0. Be sure to find the sign (+ or-) of dv/dx and of d'y/dx2 at all X values. Using the first and second derivative tests with the information you have calculated, determine which X value(s) represent maximums (MAX),...
MATLAB Only MATLAB Only MATLAB Only Indicated in the script below, write a function, called arbpoly3, that accepts two inputs: i) a row vector, called c, containing the coefficients of the polynomial, starting with the coefficient for the lowest degree term, which is the constant term. ii) a row vector, called x, which is the set of real numbers where the polynomial is to be evaluated. The output, y, will be a vector containing the values of the polynomial, evaluated...
MATLAB HELP PLEASE
Write a Matlab function that evaluates a sum of sines at a set of points. The first term is just a constant (a coefficient with no sine term). Then, each sine term will have a coefficient before it and then an increasing multiple of the angle inside. For example, consider the sum 3 + 4 sin(9)-1.5 sin (20) 2 sin (40)3 sin (50) We recognize that this is the same as 344sin(101+-1.5 sin (20) + 0 sin...