Info
This question is closed. Reopen it to edit or answer.
How to take values from .daq to .mat?
1 view (last 30 days)
Show older comments
Hello everybody. I am doing a real time acquisition using .daq of my EEGs and EMGs. By using daqread, I can extract all the values for my EEG and EMG. However, I also calculate the strength of the muscle, one value per 4 seconds. The graph is a subplot (4,2,8). How can I extract the values from the subplot and read them in .mat? Thank you!
1 Comment
Teresa Carneiro
on 16 Jun 2021
Hi! Can you show me the code you use to acquire EEG with DAQ and plot it in matlab? This is what I got but it only shows me data 1 sec at a time, and for an EEG I would like to get a continuous plot and the real time of the day on the x-axis instead of the seconds elapsed.
clear
close all
dq = daq("ni");
ch1 = addinput(dq, "Dev1", "ai0", "Voltage");
% ch2 = addinput(dq, "Dev1", "ai1", "Voltage");
dq.Rate = 1000;
dq.ScansAvailableFcn = @(src,evt) plotDataAvailable(src, evt);
dq.ScansAvailableFcnCount = 100;
start(dq, "Duration", seconds(5));
while dq.Running
pause(0.5);
end
function plotDataAvailable(src, ~)
[data, timestamps, ~] = read(src, src.ScansAvailableFcnCount, "OutputFormat", "Matrix")
plot(timestamps, data);
title('EEG','FontSize',15);
xlabel ('Elapsed Time (s)','FontSize',10); ylabel('Voltage (V)','FontSize',10);
ax = gca;
ax.YGrid = 'on';
ax.XGrid = 'on';
% legend('electrode 1','electrode 2')
drawnow
end
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!