Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello Chegg! I am in a Intro to MATLAB class and I am lost with this problem. Pl

ID: 3184330 • Letter: H

Question

Hello Chegg! I am in a Intro to MATLAB class and I am lost with this problem. Please show and explain every step legibly on how to solve it. Thanks!

1 Introduction In dynamics, when we consider kinematic variables (ã, T) during erratic motion along a direction (or axis), we often intcgrate to determine velocity attainted, distance travelled etc. These integral relations are founded on the delinitions of these kincmatic qualities and some illustrative relations are shown below. to 80 Where variables with subscript 0 are the initial valucs. While it may be possible to integrate kinematic variables analytically, there are times when such integrations are tedious In such cascs onc can resort to numcrical mcthods to integrate functions. Many modern software packages have in-built functions to integrate functions numerically. But, in this assignment you will write code in Matlab to integrate functions numcrically adopting the Simpson's mcthod

Explanation / Answer

%%% Matlab function %%%

function [sum]=simpson (f,a,b,n)
h=(b-a)/n;
sum=0;
xn=a:h:b;
for k=1:n/2
    if ( (2*k-1) > 0 )
        sum=sum+subs(f,xn(2*k-1));
    end
    if ( (2*k+1) > 0 )
        sum=sum+subs(f,xn(2*k+1));
    end
    if (2*k > 0)
        sum=sum+4*subs(f,xn(2*k));
    end
  
end
sum=sum*h/3;
end

%%% Main programm %%

clc;
clear all;
close all;
format long

%%%
syms x   %% define variable
f=x^9;   %% define function
a=1;     %% lower limit of integral
b=2;     %% higher limit of integral
n=[2 4 40 400];
for k=1:length(n)
sum=simpson(f,a,b,n(k));
fprintf(' Value of integral using n= %d is      % f ',n(k), sum);
end

OUTPUT:

Value of integral using n= 2 is       111.128906
Value of integral using n= 4 is       102.953018
Value of integral using n= 40 is       102.300069
Value of integral using n= 400 is       102.300000
>>

as value of n is increased the integral value is matched with actual integral value which is 102.3

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote