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')
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')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.