CrazyEngineers
  • Matlab Codes for Noise and Jammers

    Vila

    Vila

    @vila-4EJWAr
    Updated: Oct 27, 2024
    Views: 2.4K
    Hiiii everybody,

    Anyone have matlab codes for noise or jammers? I tried googling but can't find. Please help me get one. Thank you...
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • silverscorpion

    MemberFeb 7, 2009

    what exactly do you want? code for noise generation or noise removal..
    As to jammers, it's very easy. if you know the frequency you want to jam, you can generate some random signal of that frequency and greater amplitude. That's it.

    If you dont know the frequency, then it becomes somewhat more difficult. Then you have to use hardware also. It cant be done only with matlab code. ie, use your receiver and receive the signal. know the frequency components in it and then generate that frequency. Clear?
    Are you sure? This action cannot be undone.
    Cancel
  • Vila

    MemberFeb 8, 2009

    Hii,

    I need matlab codes for noise generation and also codes for broadband noise jammer.

    Thank you...
    Are you sure? This action cannot be undone.
    Cancel
  • silverscorpion

    MemberFeb 8, 2009

    hey you!

    I just answered your question and you are reposting the question again. I'll again tell you, we dont give you the code here. You do the code, if there are any problems, we'll be happy to help.
    Are you sure? This action cannot be undone.
    Cancel
  • durga ch

    MemberFeb 8, 2009

    Vila
    Hii,

    I need matlab codes for noise generation and also codes for broadband noise jammer.

    Thank you...
    what type of noise are you refering to?
    gaussian?
    Are you sure? This action cannot be undone.
    Cancel
  • Vila

    MemberFeb 8, 2009

    Hiii,

    Gaussian, AWGN or Broadband noise, either one can do..

    Thank you.
    Are you sure? This action cannot be undone.
    Cancel
  • Vila

    MemberFeb 8, 2009

    Hiii,

    Mmm well i have some codes here, its shows errors. to whom i have to show them to get rectified? Do i just post the codes here?

    Thank you.
    Are you sure? This action cannot be undone.
    Cancel
  • silverscorpion

    MemberFeb 8, 2009

    just post that section of the code which has errors in it. Or if it's ok for you, posting the full code is no harm, either.. Post it in this thread itself.
    Are you sure? This action cannot be undone.
    Cancel
  • durga ch

    MemberFeb 9, 2009

    Vila
    Hiii,

    Mmm well i have some codes here, its shows errors. to whom i have to show them to get rectified? Do i just post the codes here?

    Thank you.
    If your matlab has communications tool box, you have function 'awgn' which generated white gaussian noise and adds it to your signal depending on the impedance and nosie DB

    may be you can search the 'help ' section in your matlab for 'awgn' command

    for more infomration you can as well refer to the MATLAB help link
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • Vila

    MemberFeb 9, 2009

    This program should show the effect of Gaussian filter.

    %%%%%%%%%%%%% The main.m file %%%%%%%%%%%%%%%
    clear;
    % Parameters of the Gaussian filter:
    n1=10;sigma1=3;n2=10;sigma2=3;theta1=0;
    % The amplitude of the noise:
    noise=0.1;
    [w,map]=gifread(
    'lena.gif');
    x=ind2gray(w,map);
    filter1=d2gauss(n1,sigma1,n2,sigma2,theta);
    x_rand=noise*randn(size(x));
    y=x+x_rand;
    f1=conv2(x,filter1,
    'same');
    rf1=conv2(y,filter1,
    'same');
    figure(1);
    subplot(2,2,1);imagesc(x);
    subplot(2,2,2);imagesc(y);
    subplot(2,2,3);imagesc(f1);
    subplot(2,2,4);imagesc(rf1);
    colormap(gray);
    %%%%%%%%%%%%%% End of the main.m file %%%%%%%%%%%%%%%




    When i tried to run them, it shows this error message:

    Error in ==> gaussian at 7
    [w,map]=gifread('lena.gif');


    Thanks for helping...
    Are you sure? This action cannot be undone.
    Cancel
  • Vila

    MemberFeb 9, 2009

    These are another set of codes in which it should display Rayleigh function graph:


    %Initialization D=1 (D = interleaving depth)
    clear;
    Ts=1/1e3;
    % tx rate = 10k bps
    NA=10000;
    A=floor(rand(1,NA)+0.5);
    %A=randint(1,NA);
    input=A;
    G=[1 0 0; 1 0 1; 1 1 1];
    k=1;

    N=length(channel_output);
    SNRdB= -10:5:20;
    SNR=10.^(SNRdB/10);
    Counter=zeros(1,length(SNRdB));
    loop=0;

    %***************************************************************
    % AWGN + fading *
    %***************************************************************
    Fd=66; % Actual fading rate
    fm=round(Fd*NA*Ts);

    %Generate two inputs of 1 x N matrix
    xin=randn(1,(NA+2)*3);
    yin=randn(1,(NA+2)*3);

    %Loop for all values of frequencies and truncate at just before f=fm
    for f=1😔fm-1)
    filter(f)=1.5/(pi*fm*sqrt(1-(f/fm)^2));
    end
    for
    f=(fm-1)😔NA+2)*3
    filter(f)=0;
    end

    %Inputs of the filter is multiplied with the filter transfer function
    xout=xin.*filter;
    yout=yin.*filter;

    %Perform inverse Fourier Transform on both output
    xifft=real(ifft(xout));
    yifft=real(ifft(yout));

    % normaliation so that E{R^2}= 1 / in Watt = 0 dB
    std_x=std(xifft);
    std_y=std(yifft);
    xifft=xifft/std_x/sqrt(2);
    yifft=yifft/std_y/sqrt(2);

    %Sum the square the of the IFFT and take the square root of it
    rx=sqrt(xifft.^2+yifft.^2);

    %****************************************************************
    %Calculate for all value of SNRdB in AWGN + fading
    %****************************************************************
    loop=0;
    for b=sqrt(SNR) %b is the signal level
    loop=loop+1;
    dfad=0;
    for n=1😔NA+2)*3 %n = no of bits
    x=randn;
    t=channel_output(n);
    if t>=0.5
    a=b*rx(n);
    r=a+x;
    if r<0
    dfad=dfad+1;
    % error has occured, increase counter
    Df(n)=0;
    else
    Df(n)=1;
    end
    else
    a=(-b)*rx(n);
    r=a+x;
    if r>0
    dfad=dfad+1;
    Df(n)=1;
    else
    Df(n)=0;
    end
    end
    Counterf(loop)=dfad; % w/o decode
    end
    output=viterbi(G,k,Df); % E is output of decoder
    zf=0;
    v=1;
    for v=v:1:length(A);
    if xor(input(1,v),output(1,v))==1
    zf=zf+1;
    end
    end
    Counter_wcf(loop)=zf;
    end% loop for signal (b) in AWGN + fading


    %plot simulation in AWGN + fading without coding
    Pef=Counterf/N;
    %semilogy(SNRdB,Pef,'b');
    %hold on;
    %plot simulation in AWGN + fading with coding
    Pe1f=Counter_wcf/NA;
    save
    D1_66SNRdBPe1fPef
    %semilogy(SNRdB,Pe1f,'b'); %D=1 no interleaving
    %hold on;


    but when i tried running them, it shows this error message:

    Error in ==> Rayleigh at 12
    N=length(channel_output);

    Please help me..thank you
    Are you sure? This action cannot be undone.
    Cancel
  • silverscorpion

    MemberFeb 9, 2009

    In the first piece of code, try using imread() instead of gifread(). I'm not sure if a function gifread() to specifically read gif files exist.

    In the second piece of code, you dont seem to have defined what is 'channel_output'. you have used channel_output as a function in the later part of the code, and in the top part, you have tried to find the length of a function. That might be the problem.
    Are you sure? This action cannot be undone.
    Cancel
  • durga ch

    MemberFeb 9, 2009

    I dotn see channel_output being defined. Did yu put up the whole code mate?
    Are you sure? This action cannot be undone.
    Cancel
  • Vila

    MemberFeb 10, 2009

    It gives the same error even if i use imread() instead of gifread()

    Yes whole code mate, how do i define the channel_output then?
    Are you sure? This action cannot be undone.
    Cancel
  • durga ch

    MemberFeb 10, 2009

    Hi

    clear;
    Ts=1/1e3; % tx rate = 10k bps
    NA=10000;
    A=floor(rand(1,NA)+0.5);
    %A=randint(1,NA);
    input=A;
    G=[1 0 0; 1 0 1; 1 1 1];
    k=1;

    N=length(channel_output);
    SNRdB= -10:5:20;
    SNR=10.^(SNRdB/10);
    Counter=zeros(1,length(SNRdB));
    loop=0;

    if ts is your transmitted signal then your channle output should be a convolution of you input signal and noise.

    ie your channel output should be on lines of
    output = H * input;

    where H is is your channel matirx and inout in Tx
    Are you sure? This action cannot be undone.
    Cancel
  • Vila

    MemberFeb 11, 2009

    Hiii thanks a lot,

    Now i have a set of coding over here but i dont know how to determine which one is the information signal and which one is the carrier signal, wheter xin, yin, xout or yout..and what is NA?


    %Initialization D=1 (D = interleaving depth)
    clear;
    Ts=1/1e3;
    % tx rate = 10k bps
    NA=1000;
    A=floor(rand(1,NA)+0.5);
    %A=randint(1,NA);
    input=A;
    G=[1 0 1 1 0 1 1; 1 1 0 0 1 0 1; 1 1 1 1 1 0 1];
    %G=[1 0 0; 1 0 1; 1 1 1];
    k=1;
    channel_output=cnv_encd(G,k,A);
    N=length(channel_output);
    SNRdB= -10:5:20;
    SNR=10.^(SNRdB/10);
    Counter=zeros(1,length(SNRdB));
    loop=0;
    L_one=length(G)-1;
    no_rows=size(G,1);
    encoder_output_bits=(NA+L_one)*no_rows;

    %***************************************************************
    % AWGN + fading *
    %***************************************************************
    Fd=2000; % Actual fading rate
    fm=round(Fd*NA*Ts);

    %Generate two inputs of 1 x N matrix
    xin=randn(1,encoder_output_bits);
    yin=randn(1,encoder_output_bits);

    %Loop for all values of frequencies and truncate at just before f=fm
    for f=1😔fm-1)
    filter(f)=1.5/(pi*fm*sqrt(1-(f/fm)^2));
    end
    for
    f=(fm-1):encoder_output_bits
    filter(f)=0;
    end

    %Inputs of the filter is multiplied with the filter transfer function
    xout=xin.*filter;
    yout=yin.*filter;

    %Perform inverse Fourier Transform on both output
    xifft=real(ifft(xout));
    yifft=real(ifft(yout));

    % normaliation so that E{R^2}= 1 / in Watt = 0 dB
    std_x=std(xifft);
    std_y=std(yifft);
    xifft=xifft/std_x/sqrt(2);
    yifft=yifft/std_y/sqrt(2);

    %Sum the square the of the IFFT and take the square root of it
    rx=sqrt(xifft.^2+yifft.^2);

    plot(xout);
    plot(yout);

    Thank you mate...
    Are you sure? This action cannot be undone.
    Cancel
  • durga ch

    MemberFeb 11, 2009

    Vila
    Hiii thanks a lot,

    Ts=1/1e3; % tx rate = 10k bps
    NA=1000;
    A=floor(rand(1,NA)+0.5);
    %A=randint(1,NA);
    input=A;
    G=[1 0 1 1 0 1 1; 1 1 0 0 1 0 1; 1 1 1 1 1 0 1];
    k=1;
    channel_output=cnv_encd(G,k,A);

    hmm, tell me one thing has this code been picked off from the net?
    anyways
    A is your input signal. it s a randaom signal generated. NA can be any number and you rand 1,1000 .
    and your G is the convoluional encoder in polynomial representation
    Are you sure? This action cannot be undone.
    Cancel
  • Vila

    MemberFeb 12, 2009

    Hiii...yes its from the net...if A is the input signal then how about xin and yin?
    Are you sure? This action cannot be undone.
    Cancel
  • stylishdudevicky

    MemberMar 22, 2010

    Hi,
    I know few people who can write any Matlab or programming codes as a pay service. contact them at #-Link-Snipped-#
    Hope this helps.
    Are you sure? This action cannot be undone.
    Cancel
  • robben71

    MemberApr 5, 2011

    Hi, does anyone have code for gray world and white point (image processing)?
    Are you sure? This action cannot be undone.
    Cancel
  • KrishTCE

    MemberFeb 17, 2015

    Hi...... i need the verilog code for generating jamming signal......... can anyone tell me the logic for generating???
    Are you sure? This action cannot be undone.
    Cancel
  • danish salim soonka

    MemberAug 20, 2016

    i need to implement a jammer model can anyone help?
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register