I am trying to plot an audio signal on a 3D graph
2 views (last 30 days)
Show older comments
I do not have a value for the z-axis and I am not sure where to begin. Any help would be greatly appreciated!
%current fft
function currentfft(player,y,Fs)
sampleNumber=get(player,'CurrentSample');
timerVal=get(player,'TimerPeriod');
%Get channel one values for our window around the current sample number
s1=y(floor(sampleNumber-((timerVal*Fs)/2)):floor(sampleNumber+((timerVal*Fs)/2)),1);
n = length(s1);
p1 = fft(s1); % take the fourier transform
p2 = fft(p1); % take the fourier transform
p3 = fft(p2,3,750);
nUniquePts = ceil((n+1)/2);
p3 = p3(1:nUniquePts); % select just the first half since the second half
% is a mirror image of the first
p3 = abs(p3); % take the absolute value, or the magnitude
p3 = p3/n; % scale by the number of points so that
% the magnitude does not depend on the length
% of the signal or on its sampling frequency
p3 = p3.^2; % square it to get the power
% multiply by two
if rem(n, 2) % odd nfft excludes Nyquist point
p3(2:end) = p3(2:end)*2;
else
p3(2:end -1) = p3(2:end -1)*2;
end
freqArray = (0:nUniquePts-1) * (Fs / n); % create the frequency array
sz=25;
c = linspace(1,10,length(freqArray));
scatter(freqArray/2000, p3 )
xlabel('Frequency (kHz)')
ylabel('Power (watts)')
title('Frequency vs. Power')
axis([0 13 0 6]);
%this is the base code I have been using. I have tried implementing mesh and fsurf, but with no idea on how to set the z-axia correctly it was pointless.
Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!