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:

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);


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.

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

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
% size of window which goes to the next segment
%hann function
% From a row vector to a column vector
%Start index
%End index

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

    % New window

    % frequency vector

  %Plotting time segments!         
for m= 1:1:N 

    y_a = y(si:ei);
    y_a= y_a.*window;
    Ya=fft(y_a, fftlen);

      drawnow; %Updates graphical objects

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

    %% L,M,H - Bands
    y_low = Ya(f_LOW);
    ylim([-20 60]);
    title('Spektrum (LOW)');
    grid on

    y_medium = Ya(f_MEDIUM);
    ylim([-20 30]);
    title('Spektrum (MEDIUM)');
    grid on

    y_high = Ya(f_HIGH);
    ylim([-20 30]);
    title('Spektrum (HIGH)');
    grid on;

    % start index updated    
    % end index updated


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.

  • $\begingroup$ No need to apologize! Really no harm done. Your English is pretty good, too! If we don't understand something, we'll just ask :) $\endgroup$ – Marcus Müller Jan 28 '17 at 20:06
  • $\begingroup$ The problem with your post is: I don't see a clear question! What are you specifically asking? $\endgroup$ – Marcus Müller Jan 28 '17 at 20:07
  • $\begingroup$ And, your last paragraph again highlights that this might be a general programming matlab problem, and not a signal processing question at all. $\endgroup$ – Marcus Müller Jan 28 '17 at 20:07
  • $\begingroup$ Do you know matlab's surf command? It seems to be exactly what you need. mathworks.com/help/matlab/ref/surf.html $\endgroup$ – MBaz Jan 28 '17 at 23:43
  • $\begingroup$ @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. $\endgroup$ – elbertainstein Jan 28 '17 at 23:44

Browse other questions tagged or ask your own question.