MATLAB Write Matlab code that defines a function named my si

MATLAB

Write Matlab code that defines a function named my sin that computes sin(x) using the truncated power series sin(x) = Sigma^10_n=0 - 1^2n+1 x^2n + 1/(2n + 1)!

Solution

function y = sin2(x)
n = 0: 10;
c = 2*n+1;
s = (-1).^(n-1);
f = factorial(c);
for i = 1 : length(x)
    y(i) = sum(s .* x(i).^c ./ f);
end

MATLAB Write Matlab code that defines a function named my sin that computes sin(x) using the truncated power series sin(x) = Sigma^10_n=0 - 1^2n+1 x^2n + 1/(2n

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site