load 'tensionData'

Fs = 10.0;
windowName = 'Hamming';
segmentLength = 1024;
overlapPercent = 50;
%calculate the PSD
tensWSHsTest = spectrum.welch(windowName, segmentLength, overlapPercent);
tensionWSPSDDT = psd(tensWSHsTest, detrend(tensionWS), 'Fs', Fs);
tensionWSPSDNDT = psd(tensWSHsTest, tensionWS, 'Fs', Fs);

window = 1024;
nFFT = 1024;
overlap = 50;
[tensionWSPWelchDT,freqTensionWSPWelchDT] = pwelch(detrend(tensionWS),window,overlap,nFFT,Fs);
[tensionWSPWelchNDT,freqTensionWSPWelchNDT] = pwelch(tensionWS,window,overlap,nFFT,Fs);

figure
plot(tensionWSPSDDT.Frequencies, tensionWSPSDDT.Data)
title 'PSD Detrend'
figure
plot(tensionWSPSDNDT.Frequencies, tensionWSPSDNDT.Data)
title 'PSD No Detrend'
figure
plot(freqTensionWSPWelchDT, tensionWSPWelchDT)
title 'PWelch Detrend'
figure
plot(freqTensionWSPWelchNDT, tensionWSPWelchNDT)
title 'PWelch No Detrend'

