How do you get the recording in Analog Input Generator to save as a file on your computer
3 ビュー (過去 30 日間)
古いコメントを表示
I have a project in optic communication where i will send a laser beam through two polarized linses, and a lc -cell is between, further this beam while be recive at a photo dioder , and then connect to two daqs(Digital Acquisition), i have code for the output and the input signal, and everything works fine but when i record the signal in the add-on Analog Input Generator, it doesent get save anywhere, when i run the code i can get a figure of the signal.
So the big question here really is how do you save the recording as a file or something else?
I can transmit the code if necessary
Thanks in advance
0 件のコメント
回答 (1 件)
Pratyush Swain
2023 年 11 月 16 日
Hi Gabriel,
I understand you want to save the input signal recorded through the Analog Input Generator as a file. One workaround for this can be to save the data acquisition object('daq') through the code itself. The data can be saved in a 'mat' or 'csv' file and later loaded from the script itself.
Please refer to the below example implemetation for the same:
% Create DataAcquisition Object
d = dag("ni") %Replace function argument with your input source
% Add channels and set channel properties, if any.
addinput(d, "Dev1","ai@", "Voltage");
addinput(d, "Dev1","ai2@","Voltage"); %Replace input channels and as per your use-case
% Read the data in timetable format. |
DAQ_1 = read(d,seconds(1))
% Plot Data | Plot the read data on labeled axes.
plot(DAQ_1.Time, DAQ_1.Variables)
xlabel("Time")
ylabel("Amplitude (V)")
legend (DAQ_1.Properties.VariableNames)
%Save the table data to a mat file
filename_mat = 'input_data.mat';
save(filename_mat, 'DAQ_1');
%Load from mat file
loaded_data_mat = load(filename_mat);
loaded_data_mat = loaded_data_mat.data;
% Plot and Visualize data again
plot(loaded_data_mat.Time, loaded_data_mat.Variables)
xlabel("Time")
ylabel("Amplitude (V)")
legend (DAQ_1.Properties.VariableNames)
For more information please refer to https://www.mathworks.com/help/daq/acquire-data-with-the-analog-input-recorder.html and https://www.mathworks.com/help/daq/acquire-data-and-generate-signals-at-the-same-time.html
Hope this helps.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Acquisition Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!