Recording and plotting multiple channels

3 次查看(过去 30 天)
hey, if you could help me im new to matlab and would like someone to check my code. I want to record two voltage signals from our NI DAB simultaneously using two different channels. so i wrote this code. but im not sure about plotting and saving the date. i want to plot all the values in chan1 over the respective values in chan0. and then i want it to be saved in a matrix with 2 columns represented by chan0 and chan1. could you just check through my code and see if ive made any errors.
clear % Clears the workplace
close('all','hidden') % Closes all hidden and visible windows and stops all matlab processes
AI=analoginput('nidaq','Dev1'); % Generates annalog input object AI. This establishes connection between matlab and the DAB
addchannel(AI,0:1,{'chan0','chan1'}); % Connects angle sensor (chan1) and reciever (chan2)
AI.SampleRate=100; % Set sample rate on DAB
N=input ('Number of samples N: '); % Set number of voltage values to be read
set(AI,'SamplesPerTrigger',N); % Set N samples per trigger on the DAB
start(AI) % Start measurement
[UG,t]=getdata(AI); % Read voltage and corresponding time values from PC memory, and store data into the variables U and T
save('directional.dat','UG','-ascii'); % Save the file
plot(UG(:,'chan0'),UG(:,'chan1')) % Plots angle sensor signal over reciever signal
delete(AI); % Delete input object
clear AI; % Clear AI from workspace

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by