Adjust/fix the peak amplitude value
Show older comments
HI everyone,
Hope you are doing week and in good health. I need some help in modifying the code.In the following or attached Matlab file, I ma trying to generate the signal and then FFT. Then, inserting the awgn noise the certain frequencies points to show the peaks. But I am unable to fix the amplitude value whenever I run the file again and again. Every-time amplitude value is fixed. But my requirement to control the peak amplitude at fix value whatever I run 10 times but amplitude value should be fix at each peak. Just wondering if someone can help me and modify the code, it will really appreciable. Thanks for in advanced. If you need further clarification please don't hesitate tu contact with me on email adamfamily78@yahoo.co.nz
THnaks.
Regards, Aqib
====================================
{clc; clear all; close all;
Fs = 980; T = 1/Fs; L = 980; t = (0:L-1)*T;
p1 = 50; p2 = 45; p3 = 55; p4 = 5; p5 = 95; p6 = 220;
X0 = 2*sin(2*pi*p1*t); %50Hz signal X1 = 2*sin(2*pi*p2*t); %27Hz signal X2 = 2*sin(2*pi*p3*t); %67Hz signal X3 = 2*sin(2*pi*p4*t); %75Hz signal X4 = 2*sin(2*pi*p5*t); %128Hz signal X5 = 2*sin(2*pi*p6*t); %225Hz signal
%%%%%%%%%%%%%%Noisy Signal injection%%%%%%%%%%%%%%%%%%%%
peak1 = awgn(X0,30); peak2 = awgn(X1,30); peak3 = awgn(X2,30); peak4 = awgn(X3,30); peak5 = awgn(X4,30); peak6 = awgn(X5,30);
%%%% for incease and decrease the peak%%%%%% y1 = 45*log(abs(fft(peak1))); y2 = 20*log(abs(fft(peak2))); y3 = 19*log(abs(fft(peak3))); y4 = 15*log(abs(fft(peak4))); y5 = 14*log(abs(fft(peak5))); y6 = 22*log(abs(fft(peak6)));
% y=y1; m3= y1+y2+y3+y4+y5+y6; % y= y1+y2+y3+y4+y6;
% Code for writing data into text file fid1 = fopen('Y_noise.txt','w'); % open the file fprintf(fid1,'%d\t',m3); % write the data with double precision in tab separated form (you can also use comma separated form, both can be read by excel) fclose(fid1); % close the file figure (1);
plot(m3(1:250), 'r');}
Answers (0)
Categories
Find more on Get Started with Signal Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!