Question

2. Using the MATLAB integral command, numerically determine the Fourier Cosine series of the following function. Assume eac
0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc; clear; close; Defining f(x) f = @(x) 2*x.^(1.1) .* cos(3qrt(x+4)); L = 3; L = 3 Coefficient a a0 = (2/L) * integral (1,0

text :-

clc; clear; close;

% Defining f(x)
f = @(x) 2*x.^(1.1) .* cos(sqrt(x+4));
L = 3;          % L = 3

% Coefficient a0
a0 = (2/L) * integral(f,0,L);

% Using 15 terms, calculating a1,a2,a3...an and storing them in vector a
for n = 1 : 15
    integrand = @(x) f(x).*cos(n*pi*x/L);       % integrand for an for current n
    a(n) = (2/L) * integral(integrand,0,L);     % adding coefficient an in a vector
end

% Defining fourier series as a function of x
n = 1:15;           % vector of n values 1 to 15
fourier = @(x) a0./2 + sum(a.*cos(n.*x));       % fourier series

% Ploting
x = linspace(0,3);          % x vector from 0 to 3 (100 elements)
% Evaluating f(x) using fourier expansion for every x in vector x
fourier_vals = arrayfun(fourier,x);     % vector of fourier series evaluated at every x
% Ploting f(x) as red line and fourier evaluations as blue circles
plot(x,f(x),'-r',x,fourier_vals,'ob')
% Labeling the plot and setting legend
xlabel('x');
legend('f(x)','fourier cosine of f(x)','location','best')

Result :-

DO ORDINADO o -f(x) fourier cosine of f(x) .000000 Spoooo O 0.5 1 1.5 NE 2 2.5

Add a comment
Know the answer?
Add Answer to:
2. Using the MATLAB "integral" command, numerically determine the Fourier Cosine series of the following function....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT