Need help to plot frequency axis should be linear and cover the range 10 to 110 Hz in 1 Hz steps. Your vertical axis should cover from 0 to -40 dB
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% File name: ee310 project.m
clear all;
close all;
%Specify components.
Rs=1000;
C1=11.65e-6;
C2=250.1e-9;
C3=28.13e-6;
C4=603.9e-9;
L1=0.6039;
L2=28.13;
L3=0.2501;
L4=11.65;
Rl=1000;
StartFreq= 10; %lowest frequency to plot
NumDec= 11; %number of decades to plot
PtsPerDec= 10; %number of frequency points plotted per decade.
%Pre-allocate results matricies.
MagResp = zeros(NumDec*PtsPerDec,1); %matrix containing magnitude response.
Freq = zeros(NumDec*PtsPerDec,1); %matrix containing plot frequencies.
%Compute frequency response at frequency points uniformly-spaced on a log plot.
for i=1 : NumDec*PtsPerDec
Freq(i) = StartFreq+i; %Evaluate at this frequency.
s = 1j * 2*pi*Freq(i); %Determine complex frequency.
%Compute branch impedances at this frequency.
Z1 = (1/(s*C1)*(s*L1))/(1/(s*C1)+(s*L1));
Z2 = (1/(s*C2))+(s*L2);
Z3 = (1/(s*C3)*(s*L3))/(1/(s*C3)+(s*L3));
Z4 = (1/(s*C4))+(s*L4);
Vo = 1;
I1 = 1/Rl;
Va = 1 + I1*Z4;
I2 = Va/Z3;
I3 = I1 + I2;
Vb = Va + I3*Z2;
I4 = Vb/Z1;
I5 = I3 + I4;
Vin= Vb + I5 * Rs;
H = Vo/Vin;
MagResp(i) = abs(H); %Place magnitude response in result matrix.
end
%Plot magnitude.
HMag = plot(Freq,20*log10(MagResp),'color','k','linewidth',2); %Plot magnitude.
set(gca,'FontSize',12);
xlabel('Freq(Hz)');
ylabel('Response(dB)');
% ylim([-50,10]);
grid on;
0 commentaires
Réponse acceptée
Voss
le 3 Déc 2022
% File name: ee310 project.m
clear all;
close all;
%Specify components.
Rs=1000;
C1=11.65e-6;
C2=250.1e-9;
C3=28.13e-6;
C4=603.9e-9;
L1=0.6039;
L2=28.13;
L3=0.2501;
L4=11.65;
Rl=1000;
StartFreq= 10; %lowest frequency to plot
NumDec= 11; %number of decades to plot
PtsPerDec= 10; %number of frequency points plotted per decade.
%Pre-allocate results matricies.
MagResp = zeros(NumDec*PtsPerDec,1); %matrix containing magnitude response.
Freq = zeros(NumDec*PtsPerDec,1); %matrix containing plot frequencies.
%Compute frequency response at frequency points uniformly-spaced on a log plot.
for i=1 : NumDec*PtsPerDec
Freq(i) = StartFreq+i; %Evaluate at this frequency.
s = 1j * 2*pi*Freq(i); %Determine complex frequency.
%Compute branch impedances at this frequency.
Z1 = (1/(s*C1)*(s*L1))/(1/(s*C1)+(s*L1));
Z2 = (1/(s*C2))+(s*L2);
Z3 = (1/(s*C3)*(s*L3))/(1/(s*C3)+(s*L3));
Z4 = (1/(s*C4))+(s*L4);
Vo = 1;
I1 = 1/Rl;
Va = 1 + I1*Z4;
I2 = Va/Z3;
I3 = I1 + I2;
Vb = Va + I3*Z2;
I4 = Vb/Z1;
I5 = I3 + I4;
Vin= Vb + I5 * Rs;
H = Vo/Vin;
MagResp(i) = abs(H); %Place magnitude response in result matrix.
end
%Plot magnitude.
HMag = plot(Freq,20*log10(MagResp),'color','k','linewidth',2); %Plot magnitude.
set(gca,'FontSize',12);
xlabel('Freq(Hz)');
ylabel('Response(dB)');
xlim([10 110])
ylim([-40 0])
grid on;
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!