How do I downsample a signal using Octave?












1














I have been trying to downsample a signal, but I'm not sure if I have the proper command? can you give me the proper command with a brief explanation?










share|improve this question


















  • 1




    Try the resample function from the signal package: octave.sourceforge.io/signal/function/resample.html
    – am304
    Nov 19 '18 at 13:03
















1














I have been trying to downsample a signal, but I'm not sure if I have the proper command? can you give me the proper command with a brief explanation?










share|improve this question


















  • 1




    Try the resample function from the signal package: octave.sourceforge.io/signal/function/resample.html
    – am304
    Nov 19 '18 at 13:03














1












1








1







I have been trying to downsample a signal, but I'm not sure if I have the proper command? can you give me the proper command with a brief explanation?










share|improve this question













I have been trying to downsample a signal, but I'm not sure if I have the proper command? can you give me the proper command with a brief explanation?







matlab octave






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 '18 at 12:48









Mary ProgrammerWant2Be

85




85








  • 1




    Try the resample function from the signal package: octave.sourceforge.io/signal/function/resample.html
    – am304
    Nov 19 '18 at 13:03














  • 1




    Try the resample function from the signal package: octave.sourceforge.io/signal/function/resample.html
    – am304
    Nov 19 '18 at 13:03








1




1




Try the resample function from the signal package: octave.sourceforge.io/signal/function/resample.html
– am304
Nov 19 '18 at 13:03




Try the resample function from the signal package: octave.sourceforge.io/signal/function/resample.html
– am304
Nov 19 '18 at 13:03












2 Answers
2






active

oldest

votes


















3














Depending on what you are trying to achieve, the downsample can be enough.



Example code:



pkg load signal % To download the signal package
x = cos(1:1000); % Create a signal
y = downsample(x, 2);


However, it will not apply a low-pass filter so it can introduce unwanted aliasing effects on your signal. Like the command help downsample says:




For most signals you will want to use decimate instead since it prefilters the high frequency components of the signal and avoids aliasing effects.






Now if you want to downsample and apply the low-pass filter, you would like to use decimate but it only works for a downsampling with an integer factor, for example from 96kHz to 48kHz, you decimate by a factor 2. From help decimate




Note that Q must be an integer for this rate change method.




Example code:



pkg load signal % To download the signal package
x = cos(1:1000); % Create a signal
y = decimate(x, 2);




Finally, if you want to downsample by a rational number, for example by a factor of 2/3, from 96kHz to 64kHz, you will need resample like it was suggested by other users.



pkg load signal % To download the signal package
x = cos(1:1000); % Create a signal
y = resample(x, 2, 3);


Note that you can still use resample to downsample by an integer factor, for example y = resample(x, 1, 2); but it slower that decimate.






share|improve this answer































    0














    e.g.



    y=resample(x,L,M);


    .



    .



    x--> your signal



    L--> increase sampling rate



    M--> reduce sampling rate






    share|improve this answer





















    • do I have to declare L and M or is it just apart of the code?
      – Mary ProgrammerWant2Be
      Nov 19 '18 at 16:12











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375003%2fhow-do-i-downsample-a-signal-using-octave%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Depending on what you are trying to achieve, the downsample can be enough.



    Example code:



    pkg load signal % To download the signal package
    x = cos(1:1000); % Create a signal
    y = downsample(x, 2);


    However, it will not apply a low-pass filter so it can introduce unwanted aliasing effects on your signal. Like the command help downsample says:




    For most signals you will want to use decimate instead since it prefilters the high frequency components of the signal and avoids aliasing effects.






    Now if you want to downsample and apply the low-pass filter, you would like to use decimate but it only works for a downsampling with an integer factor, for example from 96kHz to 48kHz, you decimate by a factor 2. From help decimate




    Note that Q must be an integer for this rate change method.




    Example code:



    pkg load signal % To download the signal package
    x = cos(1:1000); % Create a signal
    y = decimate(x, 2);




    Finally, if you want to downsample by a rational number, for example by a factor of 2/3, from 96kHz to 64kHz, you will need resample like it was suggested by other users.



    pkg load signal % To download the signal package
    x = cos(1:1000); % Create a signal
    y = resample(x, 2, 3);


    Note that you can still use resample to downsample by an integer factor, for example y = resample(x, 1, 2); but it slower that decimate.






    share|improve this answer




























      3














      Depending on what you are trying to achieve, the downsample can be enough.



      Example code:



      pkg load signal % To download the signal package
      x = cos(1:1000); % Create a signal
      y = downsample(x, 2);


      However, it will not apply a low-pass filter so it can introduce unwanted aliasing effects on your signal. Like the command help downsample says:




      For most signals you will want to use decimate instead since it prefilters the high frequency components of the signal and avoids aliasing effects.






      Now if you want to downsample and apply the low-pass filter, you would like to use decimate but it only works for a downsampling with an integer factor, for example from 96kHz to 48kHz, you decimate by a factor 2. From help decimate




      Note that Q must be an integer for this rate change method.




      Example code:



      pkg load signal % To download the signal package
      x = cos(1:1000); % Create a signal
      y = decimate(x, 2);




      Finally, if you want to downsample by a rational number, for example by a factor of 2/3, from 96kHz to 64kHz, you will need resample like it was suggested by other users.



      pkg load signal % To download the signal package
      x = cos(1:1000); % Create a signal
      y = resample(x, 2, 3);


      Note that you can still use resample to downsample by an integer factor, for example y = resample(x, 1, 2); but it slower that decimate.






      share|improve this answer


























        3












        3








        3






        Depending on what you are trying to achieve, the downsample can be enough.



        Example code:



        pkg load signal % To download the signal package
        x = cos(1:1000); % Create a signal
        y = downsample(x, 2);


        However, it will not apply a low-pass filter so it can introduce unwanted aliasing effects on your signal. Like the command help downsample says:




        For most signals you will want to use decimate instead since it prefilters the high frequency components of the signal and avoids aliasing effects.






        Now if you want to downsample and apply the low-pass filter, you would like to use decimate but it only works for a downsampling with an integer factor, for example from 96kHz to 48kHz, you decimate by a factor 2. From help decimate




        Note that Q must be an integer for this rate change method.




        Example code:



        pkg load signal % To download the signal package
        x = cos(1:1000); % Create a signal
        y = decimate(x, 2);




        Finally, if you want to downsample by a rational number, for example by a factor of 2/3, from 96kHz to 64kHz, you will need resample like it was suggested by other users.



        pkg load signal % To download the signal package
        x = cos(1:1000); % Create a signal
        y = resample(x, 2, 3);


        Note that you can still use resample to downsample by an integer factor, for example y = resample(x, 1, 2); but it slower that decimate.






        share|improve this answer














        Depending on what you are trying to achieve, the downsample can be enough.



        Example code:



        pkg load signal % To download the signal package
        x = cos(1:1000); % Create a signal
        y = downsample(x, 2);


        However, it will not apply a low-pass filter so it can introduce unwanted aliasing effects on your signal. Like the command help downsample says:




        For most signals you will want to use decimate instead since it prefilters the high frequency components of the signal and avoids aliasing effects.






        Now if you want to downsample and apply the low-pass filter, you would like to use decimate but it only works for a downsampling with an integer factor, for example from 96kHz to 48kHz, you decimate by a factor 2. From help decimate




        Note that Q must be an integer for this rate change method.




        Example code:



        pkg load signal % To download the signal package
        x = cos(1:1000); % Create a signal
        y = decimate(x, 2);




        Finally, if you want to downsample by a rational number, for example by a factor of 2/3, from 96kHz to 64kHz, you will need resample like it was suggested by other users.



        pkg load signal % To download the signal package
        x = cos(1:1000); % Create a signal
        y = resample(x, 2, 3);


        Note that you can still use resample to downsample by an integer factor, for example y = resample(x, 1, 2); but it slower that decimate.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 21 '18 at 15:31

























        answered Nov 21 '18 at 13:23









        Bebs

        87231023




        87231023

























            0














            e.g.



            y=resample(x,L,M);


            .



            .



            x--> your signal



            L--> increase sampling rate



            M--> reduce sampling rate






            share|improve this answer





















            • do I have to declare L and M or is it just apart of the code?
              – Mary ProgrammerWant2Be
              Nov 19 '18 at 16:12
















            0














            e.g.



            y=resample(x,L,M);


            .



            .



            x--> your signal



            L--> increase sampling rate



            M--> reduce sampling rate






            share|improve this answer





















            • do I have to declare L and M or is it just apart of the code?
              – Mary ProgrammerWant2Be
              Nov 19 '18 at 16:12














            0












            0








            0






            e.g.



            y=resample(x,L,M);


            .



            .



            x--> your signal



            L--> increase sampling rate



            M--> reduce sampling rate






            share|improve this answer












            e.g.



            y=resample(x,L,M);


            .



            .



            x--> your signal



            L--> increase sampling rate



            M--> reduce sampling rate







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 19 '18 at 15:59









            Nima

            1




            1












            • do I have to declare L and M or is it just apart of the code?
              – Mary ProgrammerWant2Be
              Nov 19 '18 at 16:12


















            • do I have to declare L and M or is it just apart of the code?
              – Mary ProgrammerWant2Be
              Nov 19 '18 at 16:12
















            do I have to declare L and M or is it just apart of the code?
            – Mary ProgrammerWant2Be
            Nov 19 '18 at 16:12




            do I have to declare L and M or is it just apart of the code?
            – Mary ProgrammerWant2Be
            Nov 19 '18 at 16:12


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375003%2fhow-do-i-downsample-a-signal-using-octave%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            'app-layout' is not a known element: how to share Component with different Modules

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            WPF add header to Image with URL pettitions [duplicate]