I've been searching around for longer than I'd like to admit trying to figure out how to make a plot of frequency vs voltage. I have a series RLC circuit in which the max voltage was taken for 5 different resistances. I need to mark on both sides of the curve at 0.707 times the max voltage. I have all of these voltage values along with their corresponding frequencies but I have no idea how to create a graph in MATLAB that does this. I found this code that comes close to what I want to do but every time I try to get rid of the 6dB marker I just get errors or a blank graph.
if true % code
endfyy = linspace(0, 50, 250); % Create Data
Pyy = 0.5*exp(-(fyy-15).^2) + 0.3*exp(-(fyy-40).^2); % Create Data[pk,loc] = findpeaks(Pyy,'Npeaks',1,'SortStr','descend');db3c = 10^(-3/10); % Relative Magnitude At -3dB
db6c = 10^(-6/10); % Relative Magnitude At -6dB
ofst = 10;for k1 = 1:length(pk) varmtx = [Pyy(loc(k1)-ofst:loc(k1)); fyy(loc(k1)-ofst:loc(k1)); Pyy(loc(k1):loc(k1)+ofst); fyy(loc(k1):loc(k1)+ofst)]; dBpts(k1,1:2) = interp1(varmtx(1,:), varmtx(2,:), pk(k1)*[db6c db3c], 'linear','extrap'); dBpts(k1,3:4) = interp1(varmtx(3,:), varmtx(4,:), pk(k1)*[db6c db3c], 'linear','extrap');endif true % codeendfigure(1)plot(fyy, Pyy)hold onfor k1 = 1:length(pk) plot(dBpts(k1,:), pk(k1)*[db6c db3c db6c db3c], 'r+')endhold offgridfor k1 = 1:length(pk) fprintf(1, '\n\t-6dB frequencies = %.3f, %.3f\n', dBpts(k1,[1 3])) fprintf(1, '\n\t-3dB frequencies = %.3f, %.3f\n', dBpts(k1,[2 4]))end
Could someone please help me with this? It's supposed to look like a bell curve with the mean being the resonant frequency, and the frequencies that match up with the -3dB voltage would indicate the bandwidth.
Best Answer