I need to write code in matlab. please help 1. Plot the following function and i
ID: 2991178 • Letter: I
Question
I need to write code in matlab. please help
1. Plot the following function and its derivative: Use matlab to compute the derivative. 2. Calculate the following integrals using the command trapz, using dx=0.1. How do they compare to the theoretical values? b. Note: The integrand goes to 1 as x goes to 0. This function is also known as sinc(x), and is commonly used in communications problems. 3. Using the command integral?, find the values of the integrals from problem #2. How do they compare to the values from the trapezoid rule and theoretical values? 4. Obtain the file acceleration. XIS? from Blackboard. The first column is time (in seconds). and the second column is acceleration (in g?s). Plot acceleration versus time. 5. How much time does this file hold data for? 6. Integrate the acceleration to obtain velocity. Plot velocity versus time, Which integral command should you use? 7. Integrate the velocity to obtain position. Plot position versus time. Which integral command should you use? Notes: 1. Watch your units! 2. Label your graphs. Especially for problems 4-7, all axes must have labels representing what they are, and units. Note: 1 mg = 1 milli - g, where g = 9.8 m/s^2 is the acceleration due to gravity.Explanation / Answer
%%Question 1
syms x
f=2*x^2-5;
f_prime=diff(f);
x=linspace(0,5,100);
f1=subs(f,x);
f11=subs(f_prime,x);
figure
plot(x,f1,x,f11,'--r')
legend('function','derivative')
%%% question 2
f=@(x) 2*x.^2-5;
x=0:0.1:5;
f1=f(x);
answer=trapz(x,f1)