Plotting using surf

Hello i am trying to do this, capture audio signal using analoginput then plotting the spectrogram in realtime. this is what i have so far:
daq_object = analoginput('winsound');
chan = addchannel(daq_object,[1 2]);
x=[10];
num_samples = 1000;
axes(handles.axes1);
plot_handle=surf(T,F,10*log10(P),'edgecolor','none');
axis tight;
view(0,90);
xlabel('Time (Seconds)'); ylabel('Hz');
set(daq_object,'SamplesPerTrigger',inf,'SamplesAcquiredFcnCount',num_samples,...
'SamplesAcquiredFcn',{@update_plot,handles});
function update_plot(handles)
data = getdata(daq_object,num_samples);
[S,F,T,P] = spectrogram(data(:,1),256,250,256,1E3);
set(plot_handle,'YData',T,F,P);
end
i have few problems, first off all, initally i have this:
plot_handle=surf(T,F,10*log10(P),'edgecolor','none');
but i need to define T,F,and P.. but the problem is i don't have the audio sample yet. [since it will be in the GUI, when they press start the object will start, so audio will be started to collect].
also when i set the data,
set(plot_handle,'YData',T,F,P);
is this valid, sine the surf, function needs, T,F and P.
i am really confused, please help.
what i am trying to do is to have a real time spectrogram.

Respuestas (1)

Walter Roberson
Walter Roberson el 26 de Jul. de 2011

1 voto

You cannot achieve what you want by setting YData. See my Answer in your earlier Question as to what the YData has to be updated to contain,

4 comentarios

rave
rave el 26 de Jul. de 2011
i quite don't understand how you explained it, if you have time can you elaborate more on it. here i am only going to plot one channel, and it is a vector. i really don't understand what you explained in the topic "Set Ydata in matlab". sorry to be any inconvenience
rave
rave el 26 de Jul. de 2011
if you can show an example that would be great. please :(
Walter Roberson
Walter Roberson el 26 de Jul. de 2011
You need to read the reference information about what YData is.
http://www.mathworks.com/help/techdoc/ref/lineseriesproperties.html
rave
rave el 26 de Jul. de 2011
I tired this: set(plot_handle,'XData',T,'YData',F,'ZData',P);
still error;

Iniciar sesión para comentar.

Categorías

Más información sobre Animation en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 26 de Jul. de 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by