diff --git a/PlottingTool.mlapp b/PlottingTool.mlapp index bcad1f3..de4d10a 100644 Binary files a/PlottingTool.mlapp and b/PlottingTool.mlapp differ diff --git a/fourierPlotFnc.m b/fourierPlotFnc.m index 4a49561..d63f82b 100644 --- a/fourierPlotFnc.m +++ b/fourierPlotFnc.m @@ -14,17 +14,23 @@ function fourierPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, chan if fileSettings{2}.Value == 0 [timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel); else - %TO DO + timeArray = data(:,1); + yData = data(:, channel); end fs = 1 / fileSettings{3}.Value; - Nspec = 1024; + if length(yData) < 1024 + Nspec = length(yData) - 1; + else + Nspec = 1024; + end wspec = hamming(Nspec); Noverlap = Nspec/2; hold on figure(channel) + spectrogram(yData, wspec, Noverlap, Nspec, fs, 'yaxis'); title(channels{channel}); diff --git a/graphPlotFnc.m b/graphPlotFnc.m index 232f313..2b1d177 100644 --- a/graphPlotFnc.m +++ b/graphPlotFnc.m @@ -14,7 +14,8 @@ function graphPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, channe if fileSettings{2}.Value == 0 [timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel); else - %TO DO + timeArray = data(:,1); + yData = data(:, channel); end diff --git a/loadChannels.m b/loadChannels.m index b21e0de..019b6b8 100644 --- a/loadChannels.m +++ b/loadChannels.m @@ -1,11 +1,20 @@ -function [channels] = loadChannels(path, filenames) +function [channels] = loadChannels(path, filenamesTDMS, filenamesCSV) channels = {}; - for i = 1:length(filenames) - channel = tdmsinfo(append(path, '\', filenames(i).name)).ChannelList; + % read TDMS file headers + for i = 1:length(filenamesTDMS) + channel = tdmsinfo(append(path, '\', filenamesTDMS(i).name)).ChannelList; channel = channel{:, "ChannelName"}; channels{i} = channel; 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 \ No newline at end of file diff --git a/loadData.m b/loadData.m index c8e66dd..1cb80f3 100644 --- a/loadData.m +++ b/loadData.m @@ -1,18 +1,31 @@ -function [dataListTable] = loadData(tdmsFileList) +function [dataListTable] = loadData(tdmsFileList, csvFileList) %Convert struct to cell for easy access 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) %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. dataListTable{i} = table2array(data{1,1}); 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 diff --git a/meanPlotFnc.m b/meanPlotFnc.m index 7d58b3b..453402a 100644 --- a/meanPlotFnc.m +++ b/meanPlotFnc.m @@ -14,7 +14,8 @@ function meanPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, channel if fileSettings{2}.Value == 0 [timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel); else - %TO DO + timeArray = data(:,1); + yData = data(:, channel); end