I want to have 2 subplots with each 2 lines. One is RL and one is RC. But when I try to make a legend he only adds the RC legend to the line of the RL.
f = logspace (0, 6, 100); % vector of frequencies in log scale
R = 100; L = 1e-3; % parameters of the RL circuit
H_RL = (1i*2*pi*f*L./R)./(1+1i*2*pi*f*L./R); % transfer function (vector); use the correct equation
A = abs (H_RL); % amplitude-transfer (vector)
dFi = angle (H_RL); % fase difference (vector)
subplot (211)legend('RL')% create graph of amplitude response, A in [dB]
semilogx (f, 20 * log10 (A))grid onxlabel ('frequency [Hz]')ylabel ('response [dB]')subplot (212)legend('RL')% Create graph with phase shift, dFi in [degrees].
semilogx (f, 180 ./pi * dFi)ylim ([-180 180])grid onxlabel ('frequency [Hz]')ylabel ('phase shift [deg]')f = logspace(0, 6, 100); % vector of frequencies in log scale, omega = 2 * pi * f
R = 100; C = 1e-4; % parameters of the RC circuit
H_RC = 1./(1+2*pi*f*R*C*1i); % transfer function (vector); use the correct equationA = abs (H_RC); % amplitude response (vector)
dFi = angle (H_RC); % fase shift (vector)
subplot (211)legend('RC')hold on% create graph of amplitude response, A in [dB]semilogx (f, 20 * log10 (A))grid onxlabel ('frequency [Hz]')ylabel ('response [dB]')subplot (212)legend('RC')hold on% Create graph with phase shift, dFi in [degrees].semilogx (f, 180 ./pi * dFi)ylim ([-180 180])grid onxlabel ('frequency [Hz]')ylabel ('phase shift [deg]')
Maybe somebody knows how to fix this?
Best Answer