Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I increase/decrease (frequency/pitch) and phase using fft/ifft I think I have the basic code but I’m not sure what to do next

PS: It's done in Octave/matlab code

Example I have a signal that repeats 1 time every second and I want to have it repeat 3 times a second instead.

%Voiceprint raise lower freq phase conjugate signal
clear all, clc,clf,tic
%% Sound /beep calculation complete
[ybeep, Fsbeep, nbitsbeep] = wavread(strcat(filerawbeeppathStr,filerawbeepStr));
%addpath(”/home/rat/Documents/octave/eq_research/main/transform/”); %add path to location of functions

%1a voice print import
[vp_sig_orig, fs_rate, nbitsraw] = wavread(strcat(filevoiceprepathStr,'voice8000fs.wav')); 


%2a create frequency domain
ya_fft = fft(vp_sig_orig);
vp_sig_phase_orig = unwrap(angle(ya_fft));

%get Magnitude
ya_fft_mag = abs(ya_fft);

%3a frequency back to time domain

%adjust frequency/phase here? How?

subplot(3,1,1), plot(vp_sig_orig),title('1 original time domain')
subplot(3,1,2), plot(ya_ifft),title('2 rebuild time domain')
subplot(3,1,3), plot(vp_sig_new),title('3 adjusted time')
share|cite|improve this question
I guess it would be better to let us know what is the application you are looking at and what type of signal it is ? – Rajesh Dachiraju Apr 7 '11 at 10:30
The signal being used is audio files that are sampled at 44100 and about 2 mins long. and I'm using matlab / octave. I've been told that the best way to do this is using repmat and resample. I'll post the example code. – Rick T Apr 7 '11 at 15:01

Greetings All

I went back and did what Sergei recommended and used resample and repmat, but I'm noticing that on some of the values the rows aren't the same as the sample rate, see image link below. notice the top image value for rows says 1000 and the bottom image says rows = 1008. This happens when I change the values of resample and repmat (freq_new) but only for certain values. How can I fix this correctly? I could just delete everything after 1000 but I'm not sure if this is a bug or just the way resample/repmat works. image

here's the code in case someone may have use for it in the future PS it only works for increasing frequency.

%resample_repmat signal
clear all, clf
Fs = 1000; % Sampling rate
Ts = 1/Fs; %sampling interval
t=0:Ts:1-Ts; %sampling period

y=sin(2*pi*t*freq_orig)'; %gives a short wave

y2=resample(y,1,freq_new); %resample matrix
y3=repmat (y2,freq_new,1); %replicate matrix

[r_orig,c_orig] = size(y) %get orig number of rows and cols
[r_new,c_new] = size(y3) %get new number of rows and cols

subplot(2,1,1),plot(y),title('Orginal signal')
title(['rows=',num2str(r_orig),' cols=',num2str(c_orig)])
subplot(2,1,2),plot(y3),title('New signal')
title(['rows=',num2str(r_new),' cols=',num2str(c_new)])
share|cite|improve this answer
By changing/reversing these two lines the sample frequency will remain equal y2=repmat (y,freq_new,1); %replicate matrix y3=resample(y2,1,freq_new); %resample matrix – Rick T Apr 7 '11 at 15:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.