function [Data,params] = load_matlab(path) %LOAD_MATLAB imports EPR data recorded with MATLAB script % Usage: ['data_as_double','struct_with_parameters'] = load_matlab('C:/full/path/to/file.mat') % % Imports data exported from MATLAB workspace and extracts the filename. % Input has to be the full path to file with forwardslashes as char or % string. The extracted name is appended to the 'params' struct, whos % contents are displayed in the command window afterwards. % % Example for params output: % params = % % struct with fields: % % Field_Center: 3500 % Field_Sweep: 3400 % Field_Step: 5 % Accumulations: 100 % laser_shotreprate: 20 % Field_Start: 1800 % Field_End: 5200 % Field_Vector: [1×681 double] % mwFreq: 9.6845 % mwPower: 0.2000 % QValue: 22800 % mwAtten: 30 % mwFreqs: [681×1 double] % Name: "/some/path" %correct \ for / corrpath = replace(path,"\","/") load(corrpath,'Data','params') %get filename for further documentation and exporting figures dataname = string(extractBefore(extractAfter(path,asManyOfPattern(wildcardPattern + "/")),'.')); params.Name = dataname; %echo what information is contained in the structure called 'params' params end