diff --git a/PlottingTool.mlapp b/PlottingTool.mlapp index bcad1f3..3c37f9a 100644 Binary files a/PlottingTool.mlapp and b/PlottingTool.mlapp differ diff --git a/README.md b/README.md index d9fcd76..698aaec 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This is an attempt to standardize data plotting in Space Team Aachen, or at leas Currently, the plotting tool covers the following functionalities: -- Process “tdms” files +- Process "tdms" and "csv" files - Process multiple files at once - generate time values with increment - Automatically creates a folder-structure for the results @@ -114,15 +114,14 @@ One last disclaimer: If there is a mistake in the data set, if you use a comma i There are numerous functionalities still missing. The following list provides an overview of all important functions, that should be added as soon as possible (more or less). The order of precedence represents the priority. -1. Implement the “first row secs” functionality as described before -2. Support the file formats CSV and TXT -3. Merge plots (more than one data set in a single plot) – Maybe another tool for that? -4. Select/ Unselect all checkboxes in one column with a button -5. “Set all” button for start and end time -6. Choose the order of the move mean filter -7. Add a custom x-axis label -8. Add the option for a derivation plot -9. Allow multiple loads (Load different folder in one session) -10. Add try and catch statements around every user input +1. Support the file format TXT +2. Merge plots (more than one data set in a single plot) – Maybe another tool for that? +3. Select/ Unselect all checkboxes in one column with a button +4. “Set all” button for start and end time +5. Choose the order of the move mean filter +6. Add a custom x-axis label +7. Add the option for a derivation plot +8. Allow multiple loads (Load different folder in one session) +9. Add try and catch statements around every user input You are very welcome to help develop this tool further. If you are planning to do so, please send me a message (Max Heckmann) and I give you a short introduction in the already existing code. This probably saves you some time. \ No newline at end of file diff --git a/fourierPlotFnc.m b/fourierPlotFnc.m index 4a49561..8e253b6 100644 --- a/fourierPlotFnc.m +++ b/fourierPlotFnc.m @@ -14,17 +14,44 @@ 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 + if ending == 0 + timeArray = data(:,1); + yData = data(:, channel); + else + + timeIndex = 1; + while data(timeIndex,1) < str2double(start{channel}.Value) + timeIndex = timeIndex + 1; + end + + startIndex = timeIndex; + + while data(timeIndex, 1) <= str2double(stop{channel}.Value) || timeIndex >= length(data) + timeArray(timeIndex - startIndex + 1) = data(timeIndex,1); + timeIndex = timeIndex + 1; + end + + endIndex = timeIndex; + + for timeIndex = startIndex:endIndex - 1 + yData(timeIndex - startIndex + 1) = data(timeIndex, channel); + end + end 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..57d6ecf 100644 --- a/graphPlotFnc.m +++ b/graphPlotFnc.m @@ -14,7 +14,30 @@ 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 + + if ending == 0 + timeArray = data(:,1); + yData = data(:, channel); + else + + timeIndex = 1; + while data(timeIndex,1) < str2double(start{channel}.Value) + timeIndex = timeIndex + 1; + end + + startIndex = timeIndex; + + while data(timeIndex, 1) <= str2double(stop{channel}.Value) || timeIndex >= length(data) + timeArray(timeIndex - startIndex + 1) = data(timeIndex,1); + timeIndex = timeIndex + 1; + end + + endIndex = timeIndex; + + for timeIndex = startIndex:endIndex - 1 + yData(timeIndex - startIndex + 1) = data(timeIndex, channel); + end + end 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..eaf28c9 100644 --- a/meanPlotFnc.m +++ b/meanPlotFnc.m @@ -14,7 +14,29 @@ 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 + if ending == 0 + timeArray = data(:,1); + yData = data(:, channel); + else + + timeIndex = 1; + while data(timeIndex,1) < str2double(start{channel}.Value) + timeIndex = timeIndex + 1; + end + + startIndex = timeIndex; + + while data(timeIndex, 1) <= str2double(stop{channel}.Value) || timeIndex >= length(data) + timeArray(timeIndex - startIndex + 1) = data(timeIndex,1); + timeIndex = timeIndex + 1; + end + + endIndex = timeIndex; + + for timeIndex = startIndex:endIndex - 1 + yData(timeIndex - startIndex + 1) = data(timeIndex, channel); + end + end end