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

i want to plot f(t), amplitude response, phasor respose. using matlab but i dont

ID: 3572103 • Letter: I

Question

i want to plot f(t), amplitude response, phasor respose. using matlab but i dont know how to do.. please tell me saurce code..

i tried but it has error

n = 1:20;
a0 = 3;
b0 = -6/pi*n;
Cn = a0;

theta() = atan(-b0/a0);<--------------i dont know why it is wrong

thatan = theta();

den = (pi.^2*n.^2);

N = length(den);

for i = 1:N
    an(i) = 0;
    bn(i) = -6/den(i);
    cn = sqrt(an(i)^2+bn(i)^2);
    Cn = [Cn cn];
    theta = atan(-bn(i)/an(i));
    tetan = [thetan theta] ;
   
end

n = 0:1:20;
plot(n, Cn, '0'), grid, xlabel('n'), ylabel('Cn'), pause
plot(n, thetan, 'o'), grid, xlabel('n'), ylabel('theta n')

co f(t) = a0 + C,cos (nTtH4) Cncos (-t + .) n=1 an 0 n Ca Va +b n an 3 8AT 2n 2n 6| b 30

Explanation / Answer

theta() = represents empty array. therefore your code is failing.

Fixed code:

n = 1:20;
a0 = 3;
b0 = -6/pi*n;
Cn = a0;
theta = atan(-b0/a0);
thetan = theta;

den = (pi.^2*n.^2);
N = length(den);
for i = 1:N
an(i) = 0;
bn(i) = -6/den(i);
cn = sqrt(an(i)^2+bn(i)^2);
Cn = [Cn cn];
theta = atan(-bn(i)/an(i));
thetan = [thetan theta] ;

end
n = 0:1:20;
plot(n, Cn, '0'), grid, xlabel('n'), ylabel('Cn'), pause
plot(n, thetan, 'o'), grid, xlabel('n'), ylabel('theta n')