API download log file and convert | MATLAB
-
Moku:Go
Moku:Go Arbitrary Waveform Generator Moku:Go Data Logger Moku:Go Frequency Response Analyzer Moku:Go Logic Analyzer & Pattern Generator Moku:Go Oscilloscope & Voltmeter Moku:Go PID Controller Moku:Go Spectrum Analyzer Moku:Go Waveform Generator Moku:Go Power Supplies Moku:Go Digital Filter Box Moku:Go FIR Filter Builder Moku:Go Lock-in Amplifier Moku:Go General Moku:Go Logic Analyzer/Pattern Generator Moku:Go Time & Frequency Analyzer Moku:Go Laser Lock Box Moku:Go Phasemeter
-
Moku:Lab
Moku:Lab General Moku:Lab Arbitrary Waveform Generator Moku:Lab Data Logger Moku:Lab Digital Filter Box Moku:Lab FIR Filter Builder Moku:Lab Frequency Response Analyzer Moku:Lab Laser Lock Box Moku:Lab Lock-in Amplifier Moku:Lab Oscilloscope Moku:Lab Phasemeter Moku:Lab PID Controller Moku:Lab Spectrum Analyzer Moku:Lab Waveform Generator Moku:Lab Time & Frequency Analyzer Moku:Lab Logic Analyzer/Pattern Generator
-
Moku:Pro
Moku:Pro Arbitrary Waveform Generator Moku:Pro Data Logger Moku:Pro Frequency Response Analyzer Moku:Pro Oscilloscope Moku:Pro PID Controller Moku:Pro Spectrum Analyzer Moku:Pro Waveform Generator Moku:Pro Lock-in Amplifier Moku:Pro Digital Filter Box Moku:Pro FIR Filter Builder Moku:Pro Phasemeter Moku:Pro Multi-instrument Mode Moku:Pro General Moku:Pro Logic Analyzer/Pattern Generator Moku:Pro Time & Frequency Analyzer
- Python API
- MATLAB API
- Arbitrary Waveform Generator
- Data Logger
- Digital Filter Box
- FIR Filter Builder
- Frequency Response Analyzer
- Laser Lock Box
- Lock-in Amplifier
- Oscilloscope
- Phasemeter
- PID Controller
- Spectrum Analyzer
- Time & Frequency Analyzer
- Waveform Generator
- Logic Analyzer & Pattern Generator
- Multi Instrument Mode
- Moku Cloud Compile
- Moku general
- LabVIEW
Log and download .li file
To stream to a file (log and convert within a single script) instead of logging to a file, please refer to this article:
API streaming and stream_to_file | MATLAB
First, start a logging session and download your file. For more detailed information on the API's please visit our API Reference:
Datalogger | API Reference download_file Datalogger Examples for MATLAB
% moku example: Basic Datalogger
% (c) 2025 Liquid Instruments Pty. Ltd.
%% Connect to your Moku
i = MokuDatalogger('192.168.###.###');
try
% Set-up the Datalogger
i.set_acquisition_mode('mode','Precision');
i.set_samplerate(1e3);
i.generate_waveform(1, 'Sine', 'amplitude',1, 'frequency',10e3);
% Start the data logging session
logging_request = i.start_logging('duration',10);
log_file = logging_request.file_name;
location = logging_request.location;
% Set up to display the logging process
progress = i.logging_progress();
while progress.complete < 1
fprintf('%d seconds remaining \n',progress.time_remaining)
pause(1);
progress = i.logging_progress();
end
% Download the log file from the Moku to current directory
i.download_file(location, log_file, log_file);
fprintf('Downloaded log file to local directory. %s\n', log_file)
catch ME
% End the current connection session with your Moku
i.relinquish_ownership();
rethrow(ME)
end
% End the current connection session with your Moku
i.relinquish_ownership();
Example output:
9 seconds remaining
...
0 seconds remaining
File downloaded successfully!
Downloaded log file to local directory. MokuDataLoggerData_20250116_131731.li
Mokucli method
Ensure you have mokucli installed, you can download it from the Utilities page.
From your MATLAB Command Window, you can convert to your desired file type; csv, npy, mat, or hdf5. We'll be converting to .mat for this example.
>> ! mokucli convert MokuDataLoggerData_20250116_131731.li --format=mat
[===========================================================================]
Done.
Another method would be to call mokucli from within the script, ideally in this use case, streaming
and stream_to_file
would be used, see this article:
API streaming and stream_to_file | MATLAB
Calling mokucli from within the script is not best practice, but it is available as an option:
command = ['mokucli convert --format=mat ' log_file];
system(command,'-echo');
file_name = [log_file(1:end-2), 'mat'];
LI File Converter method
Alternatively, you can convert the file using the LI File Converter GUI, this can be accessed from the Moku: App or downloaded from the Utilities page

You can choose the file type, then drag and drop the file to the converter, or open the file from the converter using “File | Open file” or "Ctrl/Cmd + O"

Loading data from file
You can then use the converted file to load and analyze your data, adjust the file_name
and channels
parameters to match your experiment.
file_name = 'MokuDataLoggerData_20250116_131731.mat';
channels = 2;
disp(file_name);
if ~isfile(file_name)
error('Convert failed, no file received');
end
data = struct('time', [], 'ch1', []);
file = load(file_name);
data.time = file.moku.data(:, 1);
for i = 1:channels
data.(['ch', num2str(i)]) = file.moku.data(:, i+1);
end
keys = fieldnames(data);
for k = 1:numel(keys)
key = keys{k};
disp([key, ': ', mat2str(data.(key)(1:3)), ' ... [', num2str(data.(key)(end)), ']']);
end
fig = figure('Position', [100, 100, 1000, 300]);
hold on;
for i = 1:channels
plot(data.time, data.(['ch', num2str(i)]), 'DisplayName', ['Channel ', num2str(i)]);
end
title('Logged Data');
grid on;
xlabel('Time (s)');
ylabel('Voltage (V)');
legend show;
hold off;
Example output:
MokuDataLoggerData_20250116_131731.mat
time: [0;0.001;0.002] ... [9.999]
ch1: [0.00137754767956721;0.00140193458810245;0.00135472403439962] ... [0.0011665]
ch2: [0.0156492042681293;0.0155779194585648;0.0155710410997472] ... [0.015813]
