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 8966423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:01:18+00:00 2026-06-15T17:01:18+00:00

I am currently in the process of converting a MATLAB algorithm to C in

  • 0

I am currently in the process of converting a MATLAB algorithm to C in order to use it in an iOS application.

I’ve been struggling with the MATLAB’s xcorr function. Here is the relevant MATLAB code.

xcr = xcorr(A,A,maxlags);

This , according to MATLAB documentation

returns the cross-correlation sequence over the lag range [-maxlags:maxlags]. Output c has length 2*maxlags+1.

The Apple Accelerate.Framework provides a convolution/correlation function named vDSP_conv but I fail to see how to use it in a way that it produces the same output as xcorr. Is this possible ? If yes could anyone help me.

Best Regards,

Acacio

  • 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-15T17:01:19+00:00Added an answer on June 15, 2026 at 5:01 pm

    To duplicate the results of MATLAB’s xcorr, you need to pad the vector with zeroes before and after:

    #include <stdio.h>
    
    #include <Accelerate/Accelerate.h>
    
    
    int main(void)
    {
        #define NF  3
        #define NC  (2*NF+1)
    
        float A[3*NF] = {0, 0, 0, 1, 2, 3, 0, 0, 0};
        float C[NC];
    
        vDSP_conv(A, 1, A+NF, 1, C, 1, NC, NF);
    
        for (vDSP_Length i = 0; i < NC; ++i)
            printf("C[%u] = %g.\n", (unsigned) i, C[i]);
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently in the process of writing a steganography application with Qt. I am
I'm currently in the process of creating a Silverlight 3 data driven application. To
I am currently in the process of converting old Web 1.0 code to meet
I am in process of converting Visual Basic app into Python Django. Currently, it
I am converting an old cmd command to Powershell, and currently use: START My
I'm in the process of converting some queries to prepared statements and I currently
I am in the process of converting a Matlab script to an Octave one.
I'm currently in the process of converting an old bash script of mine into
Currently in the process of converting a website from its previous templating to Angular.
I'm currently in the process of converting some standard C# files so they work

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.