Draw vertical lines on a Matlab spectrophotography graph

Does the matlab spectrograph function of a locked figure function? I want to draw vertical lines on a figure, but the line function does nothing. How can I draw a line on a Matlab spectrogram?

clc; clear all; close all; [data, fs, nbits] = wavread(<INSERT WAVE FILE HERE>); % [data, fs, nbits] = wavread('white_0.05_6sec_aud.wav'); N_data=length(data); N_frame=128; N_half=N_frame/2; N_loop=N_data/(N_half); output=zeros(N_data,1); hz=0:(fs/2)/N_half:(fs/2)-(fs/2)/N_half; spectrogram(data, hanning(N_frame), N_half, N_frame, fs); x = [6500 6500]; y = [0 5.5]; H = gca; % set(gca, 'NextPlot', 'add'); % line(x, y); h = line([6500, 6500], [0, 5.5]); set(h, 'parent', handles.predicted_ax); % view(-90,90) % set(gca,'ydir','reverse') % % [y, x] = ginput(1) % view(-90, 180); 
+8
user-interface matlab
source share
1 answer

spectogram creates a surf and sets the view to (0,90) . surf sets zlim for some values ​​(depending on the spectrogram data) and, apparently, adding a line to the current chart does not change zlim (probably because spectrogram somehow blocked the axes; it should be found in edit spectrogram ). Therefore, in view(0,90) line disappears completely (turn the graph, you will see that the line appears somewhere above the surface).

To solve: the way to add a string by default corresponds to a string containing z coordinates [0 0] , which for many spectrogram s will be above the range of axes set on the spectrogram .

Issue

 zl = zlim; axis([xlim ylim zl(1) max(0, zl(2))]) view(0,90) 

after line should make a line.

Also: in my case, the surface that the line hung over was mostly blue, like the line. This does not help to make the presence of the line obvious :) I made it white, which contrasted better with the blue / yellow / red surf below.

+4
source share

All Articles