Azzera filtri
Azzera filtri

How do you get the recording in Analog Input Generator to save as a file on your computer

4 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Pratyush Swain
Pratyush Swain il 16 Nov 2023
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)
Hope this helps.

Categorie

Scopri di più su Periodic Waveform Generation in Help Center e File Exchange

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by