31 lines
843 B
Matlab
31 lines
843 B
Matlab
%% read_wpd_csv.m
|
|
% Minimal importer for WebPlotDigitizer multi-curve CSV
|
|
|
|
filename = 'wpd_datasets.csv'; % <-- set your file path here
|
|
T = readtable(filename);
|
|
|
|
% Read header row manually
|
|
fid = fopen(filename);
|
|
hdr1 = strsplit(strrep(fgetl(fid), '"', ''), ','); % curve names
|
|
hdr2 = strsplit(strrep(fgetl(fid), '"', ''), ','); % X/Y header row
|
|
fclose(fid);
|
|
|
|
% Extract unique curve names
|
|
names = hdr1(~cellfun('isempty',hdr1));
|
|
|
|
% Create struct for each curve
|
|
mii = struct();
|
|
for i = 1:numel(names)
|
|
base = matlab.lang.makeValidName(strrep(names{i},' ','_'));
|
|
xi = 2*(i-1)+1; % X column
|
|
yi = xi+1; % Y column
|
|
mii.(base).X = T{:,xi};
|
|
mii.(base).Y = T{:,yi};
|
|
|
|
% also create workspace variable "name_wpd"
|
|
assignin('base',[base '_wpd'], mii.(base));
|
|
end
|
|
|
|
disp('Imported datasets:');
|
|
disp(fieldnames(mii));
|