Added CSV file support, scrolling to allow for more data, and implemented first row secs option.

This commit is contained in:
@CarlWachter 2023-01-17 15:02:30 +01:00
parent bf8b42d432
commit 067a6d1d1a
6 changed files with 41 additions and 11 deletions

Binary file not shown.

View File

@ -14,17 +14,23 @@ function fourierPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, chan
if fileSettings{2}.Value == 0 if fileSettings{2}.Value == 0
[timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel); [timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel);
else else
%TO DO timeArray = data(:,1);
yData = data(:, channel);
end end
fs = 1 / fileSettings{3}.Value; fs = 1 / fileSettings{3}.Value;
if length(yData) < 1024
Nspec = length(yData) - 1;
else
Nspec = 1024; Nspec = 1024;
end
wspec = hamming(Nspec); wspec = hamming(Nspec);
Noverlap = Nspec/2; Noverlap = Nspec/2;
hold on hold on
figure(channel) figure(channel)
spectrogram(yData, wspec, Noverlap, Nspec, fs, 'yaxis'); spectrogram(yData, wspec, Noverlap, Nspec, fs, 'yaxis');
title(channels{channel}); title(channels{channel});

View File

@ -14,7 +14,8 @@ function graphPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, channe
if fileSettings{2}.Value == 0 if fileSettings{2}.Value == 0
[timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel); [timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel);
else else
%TO DO timeArray = data(:,1);
yData = data(:, channel);
end end

View File

@ -1,11 +1,20 @@
function [channels] = loadChannels(path, filenames) function [channels] = loadChannels(path, filenamesTDMS, filenamesCSV)
channels = {}; channels = {};
for i = 1:length(filenames) % read TDMS file headers
channel = tdmsinfo(append(path, '\', filenames(i).name)).ChannelList; for i = 1:length(filenamesTDMS)
channel = tdmsinfo(append(path, '\', filenamesTDMS(i).name)).ChannelList;
channel = channel{:, "ChannelName"}; channel = channel{:, "ChannelName"};
channels{i} = channel; channels{i} = channel;
end end
% read CSV file headers
for i = length(filenamesTDMS) + 1:length(filenamesCSV) + length(filenamesTDMS)
channel = readtable(strcat(path, '\', filenamesCSV(i - length(filenamesTDMS)).name), ...
'VariableNamingRule','preserve');
channel = channel.Properties.VariableNames;
channel = string(channel);
channels{i} = channel.';
end
end end

View File

@ -1,18 +1,31 @@
function [dataListTable] = loadData(tdmsFileList) function [dataListTable] = loadData(tdmsFileList, csvFileList)
%Convert struct to cell for easy access %Convert struct to cell for easy access
tdmsFileList = struct2cell(tdmsFileList); tdmsFileList = struct2cell(tdmsFileList);
if width(tdmsFileList) > 0
path = tdmsFileList{2, 1};
else
path = csvFileList(1).folder;
end
%load TDMS files
for i = 1:width(tdmsFileList) for i = 1:width(tdmsFileList)
%Read files and save them as a table in a list %Read files and save them as a table in a list
data = tdmsread(strcat(tdmsFileList{2, i}, '\', tdmsFileList{1, i})); data = tdmsread(strcat(path, '\', tdmsFileList{1, i}));
%Take the table out of an 1x1 cell array and convert it in a cell array. %Take the table out of an 1x1 cell array and convert it in a cell array.
dataListTable{i} = table2array(data{1,1}); dataListTable{i} = table2array(data{1,1});
end end
%load CSV files
for i = width(tdmsFileList) + 1: length(csvFileList) + width(tdmsFileList)
%Read CSV files
dataListTable{i} = readmatrix(strcat(path, '\', csvFileList(i - width(tdmsFileList)).name));
end
end end

View File

@ -14,7 +14,8 @@ function meanPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, channel
if fileSettings{2}.Value == 0 if fileSettings{2}.Value == 0
[timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel); [timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel);
else else
%TO DO timeArray = data(:,1);
yData = data(:, channel);
end end