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

  • Home
  • SEARCH
  • 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 6713155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:20:45+00:00 2026-05-26T08:20:45+00:00

I have a problem understanding some code fragment from Matlab Signal processing Toolbox fir2()

  • 0

I have a problem understanding some code fragment from Matlab Signal processing Toolbox fir2() function:

% My comment: at this point vector H contains nn+1 (nn is an even number) points (double numbers) of amplitudes for a dense frequency grid


% Fourier time-shift.
dt = 0.5 .* (nn - 1);
rad = -dt .* sqrt(-1) .* pi .* (0:npt-1) ./ (npt-1);
H = H .* exp(rad);
%My comment: now H contains nn+1 complex numbers 


%My comment: creates a horizontal mirror with 2*nn points    
Hconj = [H conj(H(npt-1:-1:2))];   % Fourier transform of real series.
ht = real(ifft(Hconj));            % Symmetric real series.

%My comment: throws away the half after ht[nn]
b = ht(1:nn);         % Raw numerator.
wind = hamming(nn);
b = b .* wind(:).';   % Apply window.

What confuses me is:
– if I comment out that Fourier time-shift, the result of ifft is symmetrical around ht[nn]
– if I leave Fourier time shift code intact, the result of ifft is no longer symmetrical around ht[nn] but it has two symmetrical groups around ht[nn/2] and ht[3*nn/4], while both parts around ht[nn] look really different in a plot. But everything after ht[nn] is thrown away, so if I need the final output to be symmetrical, I have to leave that Fourier time shift.

Why is that Fourier time shift needed? Can I replace it with some simpler algorithm in my C++ application which is not using complex numbers and still get out nn points with symmetry around ht[nn/2] so I can throw away everything after ht[nn]?

P.S. I just looked at the plots with and without Fourier timeshift and noticed that I can get the same result by shifting the second result nn/2 to the right. So theoretically I could avoid using Fourier time shift in my C++ application but just shift the real results of ifft by nn/2 to the right and then throw away everything after nn. Am I right? Is it safe to do?

  • 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-05-26T08:20:46+00:00Added an answer on May 26, 2026 at 8:20 am

    According to this paper, the time-shift is needed for causal filter design. To quote,

    If a zero phase shift was specified for each <Hd(F) then the
    resulting h(n) would be centered at the origin. Hence a minimum
    delay of g = (M-1)/2 samples is needed to make the filter causal. By
    the time-shift property of the DTFT, this corresponds to
    multiplication of |Hd(F)| by exp(-j*g*2*pi*F).

    In other words, you can bypass frequency-domain time-shift and still get the right filter back, but it simply will not be causal. It will sill have symmetry and be centered at the origin.

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

Sidebar

Related Questions

hello everyone I have some problem with understanding this piece of the code: import
the biggest problem I have is understanding why some of my code wont work
I have an understanding problem of how the following code works: XMLInputFactory xif =
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
i'm starting to work with php basics and i have some problem understanding how
I'm new to Ruby, so I'm having some trouble understanding this weird exception problem
I have some javascript code (within an object) : toggle: function() { var me
I think I have some basic understanding problem so maybe someone's able to help
I have some problem understanding the compound assignment operator and the assignment operator in
Im having some problems understanding some code in a programme I have inherited. CGPoint

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.