Skip to content

Instantly share code, notes, and snippets.

@zaman
Created June 16, 2011 21:46
Show Gist options
  • Save zaman/1030372 to your computer and use it in GitHub Desktop.
Save zaman/1030372 to your computer and use it in GitHub Desktop.
%Simple analog diaplay
figure(2)
%define the input
adaptor = 'winsound';
id = 0;
chan = 1;
% Analog input object Configuration.
% Create an analog input object with one channel.
ai = analoginput(adaptor, id);
ch = addchannel(ai, chan);
% Configure the analog input rate.
set(ai, 'SampleRate', 44100);
% Configure the analog input object to trigger manually.
set(ai, 'SamplesPerTrigger', 441); % 1/100 second
set(ai, 'TriggerRepeat', 1);
set(ai, 'TriggerType', 'manual');
% Object Execution.
% Start the analog input object.
for i=1:50
%start data collection and trigger it
start(ai);
trigger(ai);
% Obtain the available time and data.
[data,time] = getdata(ai, ai.SamplesPerTrigger);
stop(ai)
%plot the data and set axes
plot(time,data,'w');
set(gca, 'XLim', [0 get(ai,'SamplesPerTrigger')/44100]);
set(gca, 'YLim', [-1 1]);
set(gca, 'color', [.1 .4 .2]);
grid on
% Label the plot.
xlabel('Time (sec)');
ylabel('Winsound.0 (Volts)');
drawnow
end
delete(ai);
clf;
@zaman
Copy link
Author

zaman commented Jun 16, 2011

@semihozkoroglu & @seddi bu kodu inceleyelim basit bir AnalogInput alımı gerçeklenmiş.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment