I had two signal one is periodic and the other is aperiodic.for example

period like--> waveformPeriodic = [t1,sin(t1/10)];

aperiodic like--> waveformAperiodic = [sort(rand(100,1)*100),rand(100,1)];

How can I generate the amplitude/phase spectra and Fourier transform for them??

period like--> waveformPeriodic = [t1,sin(t1/10)];

aperiodic like--> waveformAperiodic = [sort(rand(100,1)*100),ran

How can I generate the amplitude/phase spectra and Fourier transform for them??

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get this solution by purchasing an Individual license!
Start your 7-day free trial.

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trialHi Gordon

I think I will pick 2 wave file for my aperiodic signal and periodic signal. So the presentation would like below, how can I generate the amplitude spectra, phase spectra, and FT. since i am very new to matlab i think it looks like easier for me... could you please help me about this. thank you in advance...

aperiodicwav = wavread('aperiod.wav');

[aper, f] = wavread('aperiod.wav');

periodicwav = wavread('period.wav');

[per, fc] = wavread('period.wav');

subplot(2,2,1), plot(aper), title('Entire waveform of aperiodic signal');

smallRange = 100000:100000+floor(f/100)

subplot(2,2,2), plot(per), title('Entire waveform of periodic signal');

smallRange = 100000:100000+floor(fc/100

subplot(2,2,3), plot(?????????), title('phase spectra of aperiod signal'); -------> how can I plot "aperiod" signal'samplitude spectra, phase spectra, and FT here？

subplot(2,2,4), plot(???????), title('phase spectra of aperiod signal'); -------->how can I plot "period" signal'samplitude spectra, phase spectra, and FT here？

The answer I gave you already contains examples for how to achieve this.

If you need additional help please could you accept my answer and then ask a new question ?

Thanks,

Gordon

I need to earn more points to get to Premium Membership.

If you think the answer I gave you was worth points (and hopefully you do because there's alot there) please could you accept it ?

Thanks,

Gordon

Math / Science

From novice to tech pro — start learning today.

Experts Exchange Solution brought to you by

Enjoy your complimentary solution view.

Get this solution by purchasing an Individual license!
Start your 7-day free trial.

Lets just take waveformPeriodic as our example.

Save the code at the end of this message to a file called "fftden.m" somewhere on your matlab search path, then issue the following command to see an fft plot of your data :

>> fftden(waveformPeriodic(:,

Issue the following slightly different command to return amplitude and phase spectra instead of generating a plot :

>> [freq,density,phaseDeg] = fftden(waveformPeriodic(:,

Gordon

>>>>>>>>>>>>>>>>>>>>>>>>>>

CUT AND PASTE THE FOLLOWING CODE INTO A FILE CALLED fftden.m

>>>>>>>>>>>>>>>>>>>>>>>>>>

function [freq,density,phaseDeg] = fftden(tIn,xIn,sampleFreq)

% [freq,density,phaseDeg] = fftden(t,x,sampleFreq)

% generate a power spectral density from a time domain signal using fft

% density should scale with neither sampleFreq nor length of xIn

%

% if no outputs are requested then a plot is generated

% an example is given is the function is executed with no inputs

if nargin>0

if nargin < 3 || isempty(sampleFreq)

sampleFreq = 1/min(diff(tIn));

end

t = min(tIn):1/sampleFreq:max(

x = interp1(tIn,xIn,t);

n = 2^(nextpow2(length(x))); % use next highest power of 2 greater than or equal to length(x)

fftOut = fft(x,n); % take fft, padding with zeros so that length(fftOut) is equal to n

fftMag = fftOut.*conj(fftOut);

warning off MATLAB:divideByZero

fftPhase = 180*atan(imag(fftOut)./rea

warning on MATLAB:divideByZero

i = 1:(1+n/2);

freq = (i-1)*sampleFreq/n;

density = fftMag(i)/(n*sampleFreq);

phaseDeg= fftPhase(i);

if nargout==0

figure

plot(freq,density,'b', freq,density,'b.');

xlabel('Frequency (Hz)');

ylabel('Power Spectral Density');

grid on

zoom on

end

else

if nargin>0

error('Can''t generate outputs without inputs. Use "fftden;" to see example.')

end

figure

oi = 0.001; %1024 2048 4096 8192

t=0:1/1024:1; [f,d]=fftden(t,sin(2*pi*t*

t=0:1/1024:1; [f,d]=fftden(t,sin(2*pi*t*

t=0:1/1024:1; [f,d]=fftden(t,sin(2*pi*t*

t=0:1/1024:1; [f,d]=fftden(t,sin(2*pi*t*

t=0:1/1024:2; [f,d]=fftden(t,sin(2*pi*t*

t=0:1/1024:3; [f,d]=fftden(t,sin(2*pi*t*

t=0:1/1024:4; [f,d]=fftden(t,sin(2*pi*t*

t=0:1/1024:5; [f,d]=fftden(t,sin(2*pi*t*

title('Example set of Frequency Distributions');

xlabel('Frequency (Hz)');

ylabel('Power Spectral Density');

grid on

zoom on

end