How do I downsample a signal using Octave?
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
add a comment |
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
1
Try theresample
function from thesignal
package: octave.sourceforge.io/signal/function/resample.html
– am304
Nov 19 '18 at 13:03
add a comment |
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
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
matlab octave
asked Nov 19 '18 at 12:48
Mary ProgrammerWant2Be
85
85
1
Try theresample
function from thesignal
package: octave.sourceforge.io/signal/function/resample.html
– am304
Nov 19 '18 at 13:03
add a comment |
1
Try theresample
function from thesignal
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
add a comment |
2 Answers
2
active
oldest
votes
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
.
add a comment |
e.g.
y=resample(x,L,M);
.
.
x--> your signal
L--> increase sampling rate
M--> reduce sampling rate
do I have to declare L and M or is it just apart of the code?
– Mary ProgrammerWant2Be
Nov 19 '18 at 16:12
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
.
add a comment |
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
.
add a comment |
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
.
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
.
edited Nov 21 '18 at 15:31
answered Nov 21 '18 at 13:23
Bebs
87231023
87231023
add a comment |
add a comment |
e.g.
y=resample(x,L,M);
.
.
x--> your signal
L--> increase sampling rate
M--> reduce sampling rate
do I have to declare L and M or is it just apart of the code?
– Mary ProgrammerWant2Be
Nov 19 '18 at 16:12
add a comment |
e.g.
y=resample(x,L,M);
.
.
x--> your signal
L--> increase sampling rate
M--> reduce sampling rate
do I have to declare L and M or is it just apart of the code?
– Mary ProgrammerWant2Be
Nov 19 '18 at 16:12
add a comment |
e.g.
y=resample(x,L,M);
.
.
x--> your signal
L--> increase sampling rate
M--> reduce sampling rate
e.g.
y=resample(x,L,M);
.
.
x--> your signal
L--> increase sampling rate
M--> reduce sampling rate
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
Try the
resample
function from thesignal
package: octave.sourceforge.io/signal/function/resample.html– am304
Nov 19 '18 at 13:03