Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8041115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:06:42+00:00 2026-06-05T04:06:42+00:00

I try to show spectrum of simple sin wave as we know a single

  • 0

I try to show spectrum of simple sin wave as we know a single sin wave with fixed frequency must have on peak in its spectrum I write this code but I can’t get this one peak what is wrong in my code:

clc
nsteps=200;%number of signal elements in time domain
i=sqrt(-1);
NFREQS=100;%number of elements in frequency domain
ddx=1e-9;
dt=ddx/(6e8);%separation between each time domain elements
lambdai=150e-9;
lambdaf=500e-9;
freqi=3e8/lambdai;
freqf=3e8/lambdaf;
freq=zeros(1,NFREQS);
for j=1:NFREQS
freq(j)=freqi-j*(freqi-freqf)/NFREQS;%desired frequency domain
end
arg=2*pi*freq*dt;
et=zeros(nsteps,1);
    for j=1:nsteps
       et(j)=sin(2*pi*3e15*j*dt);%sin wave in time domain
    end
e=zeros(NFREQS,1);
for n=1:NFREQS
for j=1:nsteps  
 e(n)=e(n)+et(j)*exp(-i*arg(n)*n);%sin wave in frequency domain
end
end
lambda=linspace(lambdai,lambdaf,NFREQS);
plot(lambda,abs(e))

The result is here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:06:44+00:00Added an answer on June 5, 2026 at 4:06 am

    The key point in here is using window function. The resulted code is this:

    clc
    clear
    nsteps=40000;
    i=sqrt(-1);
    Sc=0.5;
    ddx=1e-9;
    dt=ddx*Sc/(3e8);
    lambdai=100e-9;
    lambdaf=700e-9;
    lambda=lambdai:1e-9:lambdaf;
    [m,NFREQS]=size(lambda);
    
        freq=3e8./lambda;
    et=zeros(nsteps,1);
        for j=1:nsteps
           et(j)=sin(2*pi*3e8/(300e-9)*dt*j);%sin wave in time domain
        end
        w=blackman(nsteps);%window function for periodic functions 
        for j=1:nsteps
            et(j)=et(j)*w(j);
        end
        e=zeros(1,NFREQS);
        for n=1:NFREQS
            for j=1:nsteps
                e(n)=e(n)+et(j)*exp(-i*2*pi*freq(n)*dt*j);
            end
        end
       plot(lambda,abs(e))
    

    And the result is:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one Activity in which I try to show some simple messages, and
I have a JPG image in buffer and I would try to show it
I have a little problem with jQuery. I try to show multiple texts in
I have the following code and i try to show text in text-view which
I have a problem where I try to show a modal box, it's when
Hi, I try to show a div on click and then jump to its
Helo everyone! I have this live wallpaper in witch I try to show a
I have the following three classes: When I try to show a progressDialog when
i try to show and hide divs on click but something isnt going wel
This compiles: class Ex1 { public int show() { try { int a=10/10; return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.