# Visualising fft-signal [closed]

Firstly, I apologize for asking several question in a short time, since it was kinda important for me. It was not my intention to be rude, so i created this account. Another thing to take into consideration, is that my english skills and my knowledge in matlab-programming or in general is limited, therefore it makes it really hard, to ask a "good" question. Simply said, it is difficult to explain my problem, but i try my best. Please consider this. Also, my code works at the moment, but i need to a few steps and i don't know how. PLEASE, provide an answer, solution or even an advice based on MY CODE. And i only want it to do it on matlab, since i don't know the other languages. If there is nothing, that can help me, i won't bother anymore and delete this account.

## Anyway to my question:

As you may know, i have an audiofile (music) on which i compute a STFT. I want to visualise it. See the following explanation in my code. Read the comments!

My first idea to do this way, was using the function "mesh" or something similar.

Here is my mesh-code:

X=1:10;
Y=1:15;
Z = [];

% Here i would define the number of time segments
% See the next following code, to understand, what i mean.
for i = 1:length(X)

% Here in this line, i want to compute my short fft
%

% number of frequencies
for j = 1: length(Y)
Z(j,i) = 1.0/(i*j);
end
end

mesh(X,Y,Z)


This code plots me a mesh, i just wanted to know for myself, how this works. Anyway please be aware, that i am quite sure that i do not know, how the function "mesh" works to the fullest, but i think, i understood most of it. Another thing i need to mention is, that i am defining frequency bands in my next following code. I did this, because i noticed, i have very high amplitudes in a range from 1 - 1000Hz, which is why, i defined 3 frequency bands. It is not necessary to plot all of them, but i want to visualise at least one. Not visualising the whole frequency range from the audio signal, but only the specificially chosen band.

%% MATLAB
%_________________________________________
% y = Vector, which contains audio signal
% fs = Sample Rate
% 'dontstopmenow' = WAV-file
%_________________________________________

%PARAMETER FOR STFT
%_________________________________________
t_seg=0.03; % Length of segment in ms

fftlen = 4096; %FFT-Points

%Defining the length of my frequency bands
f_LOW= 1:200;    % contain lower frequencies
f_MEDIUM= 201:600;  % contain medium frequencies
f_HIGH= 601:1000; % contain higher frequencies

%_______________________________________________________

segl =floor(t_seg*fs);
% Length of segment, on which we use the fft
% "floor" rounds off the result
windowshift=segl/2;
% size of window which goes to the next segment
window=hann(segl);
%hann function
window=window.';
% From a row vector to a column vector
si=1;
%Start index
ei=segl;
%End index

N= length(y)/windowshift - 1;
% Number of time segements in audio signal

f1=figure;
% New window

f=0:1:fftlen-1;
f=f/(fftlen-1)*fs;
% frequency vector

Ya=zeros(1,fftlen);
%Plotting time segments!
for m= 1:1:N

y_a = y(si:ei);
y_a= y_a.*window;
Ya=fft(y_a, fftlen);
Ya=abs(Ya(1:end/2));
%One-sided-spectrum

figure(f1);
plot(f(1:end/2), 20*log10(Ya));
%STFT __ plots the whole audio signal after a stft, every 30ms

%% L,M,H - Bands
subplot(3,1,1)
y_low = Ya(f_LOW);
plot(f_LOW,y_low);
ylim([-20 60]);
title('Spektrum (LOW)');
xlabel('f(Hz)');
ylabel('dB');
grid on

subplot(3,1,2)
y_medium = Ya(f_MEDIUM);
plot(f_MEDIUM,y_medium);
ylim([-20 30]);
title('Spektrum (MEDIUM)');
xlabel('f(Hz)');
ylabel('dB');
grid on

subplot(3,1,3)
y_high = Ya(f_HIGH);
plot(f_HIGH,y_high);
ylim([-20 30]);
title('Spektrum (HIGH)');
xlabel('f(Hz)');
ylabel('dB');
grid on;

si=si+windowshift;
% start index updated
ei=ei+windowshift;
% end index updated

end


Yes, i know there is a function (spectogram), which could my code shorter than this, but i prefer this method. And i am pretty sure, i need to do it this way. You see, the point is, when i do a stft every 30 ms, then i want to see this in my 3-dimensional graph(?). I want to make it visual, but i need to friggin know, how to define this 3 axes or a codeline. Bascially combining the mesh code with my stft code. If any question, please ask.

## closed as unclear what you're asking by Marcus Müller, A_A, jojek♦Jan 29 '17 at 18:31

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• No need to apologize! Really no harm done. Your English is pretty good, too! If we don't understand something, we'll just ask :) – Marcus Müller Jan 28 '17 at 20:06
• The problem with your post is: I don't see a clear question! What are you specifically asking? – Marcus Müller Jan 28 '17 at 20:07
• And, your last paragraph again highlights that this might be a general programming matlab problem, and not a signal processing question at all. – Marcus Müller Jan 28 '17 at 20:07
• Do you know matlab's surf command? It seems to be exactly what you need. mathworks.com/help/matlab/ref/surf.html – MBaz Jan 28 '17 at 23:43
• @MarcusMüller Yes, i wasn't really sure, if it concern signal processsing or not, but i thought, i just give it a try. I imagined that audio signal also belongs to signal processing, maybe not manipulating the signal itself. – elbertainstein Jan 28 '17 at 23:44