What do I need to add to my code when using loglog to plot?
Learn how to use loglog plots in MATLAB! This guide covers essential code additions for effective logarithmic plotting, ensuring accurate and insightful data vi
Learn how to use loglog plots in MATLAB! This guide covers essential code additions for effective logarithmic plotting, ensuring accurate and insightful data vi
the mistake is in the line when you call the loglog function.
loglog(Fv, 20*log10(abs(FT_af(Iv,2))*2)), xlabel('Frequency, Hz', ylabel('Amplitude, dB'));
you are using the function ylabel as an argument for xlabel, while instead you should separate those commands.
loglog(Fv, 20*log10(abs(FT_af(Iv,2))*2)); xlabel('Frequency, Hz'); ylabel('Amplitude, dB');
Given the fact that you also call xlabel and ylabel later in the script, i would suggest you to just keep the last xlabel and ylabel calls in the following way:
[audio_file, Fs] = audioread("Handgun.wav"); L = size(audio_file,1); Ts = 1/Fs; % Sampling Interval Fn = Fs/2; % Nyquist Frequency FT_af = fft(audio_file)/L; % Fourier Transform Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector Iv = 1:numel(Fv); % Index Vector [PksL,LocsL] = findpeaks(20*log10(abs(FT_af(Iv,2))*2), 'MinPeakHeight',-90, 'MinPeakDistance',50); [PksR,LocsR] = findpeaks(20*log10(abs(FT_af(Iv,2))*2), 'MinPeakHeight',-90, 'MinPeakDistance',50); figure(1); loglog(Fv, 20*log10(abs(FT_af(Iv,2))*2)); hold on loglog(Fv(LocsR), PksR, '^r', 'MarkerFaceColor','r') hold off xlabel('Frequency (Hz)') ylabel('Amplitude (dB)') title('Handgun')
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.