Code covered by the BSD License
-
aplicacao(varargin)
APLICACAO M-file for aplicacao.fig
-
daqstopbutton_custom(fig,obj,...
DAQSTOPBUTTON Add a stop/start button to a data acquisition application
-
daqwaterfall(varargin)
daqwaterfall
-
untitled(varargin)
UNTITLED M-file for untitled.fig
-
createfigure(data_real1, data...
CREATEFIGURE(X1,Y1,DATA_REAL1,DATA_IMAG1,DATA_ABS1,DATA_IDEX1)
-
importfile(fileToRead1)
IMPORTFILE(FILETOREAD1)
-
soundcard( )
Define Soundcard input
-
vsunitcircle(data_real1, data...
VSUNITCIRCLE(DATA_REAL1,DATA_IMAG1)
-
vsunitcircle(data_real1, data...
VSUNITCIRCLE(DATA_REAL1,DATA_IMAG1)
-
setup.m
-
View all files
|
|
| soundcard( )
|
function soundcard( )
%% Define Soundcard input
ai = analoginput('winsound');
addchannel(ai, 1);
%% Configure
% Now, let's set up the analog input object so that we acquire 5 seconds of
% data at 8000 Hz as soon as the object is started.
Fs=8000;
Ns=800;
ai.SampleRate = Fs;
ai.SamplesPerTrigger = Ns;
ai.TriggerType = 'Immediate';
ai.TriggerRepeat = Inf;
%% Start acquisition
start(ai)
pause(0.2)
%% Collect and plot
% Each time you execute this cell, new data is acquired and plotted. Dock
% the figure in the desktop for best results.
[d] = peekdata(ai,Ns);
plot(d);
ylim([-.25 .25])
%% Analyze and plot
% Each time you execute this cell, new data is acquired, fft calculated and
% plotted. Dock the figure in the desktop for best results.
d = peekdata(ai,Ns);
y=abs(fft(d)).^2;
f=(0:Fs/Ns:Fs/2-1);
semilogy(f,y(1:length(y)/2));
ylim([1e-5 1e3]);
%% Put analysis and plotting in loop, fix and annotate axis
for k= 1:200
d = peekdata(ai,Ns);
y=abs(fft(d)).^2;
semilogy(f,y(1:length(y)/2));
axis tight;
ylim([1e-5 1e3]);grid;
ylabel('Amplitude');
xlabel('Frequency');
drawnow;
end;
%% Clear up
stop(ai);
ai.SamplesPerTrigger=8000;
delete(ai);
|
|
Contact us at files@mathworks.com