sw-plotting-tool/graphPlotFnc.m
2023-01-20 12:26:03 +01:00

65 lines
2.0 KiB
Matlab

function graphPlotFnc(data, fileSettings, checkboxes, start, stop, yAxis, xAxis, channels, path)
%Iterate through all channels
for channel = 1:width(data)
%If Graph is checked
if checkboxes{channel}.Value == 1
%Convert start and ending time
beginning = str2double(start{channel}.Value);
ending = str2double(stop{channel}.Value);
%if first row increment is not checked
if fileSettings{2}.Value == 0
[timeArray, yData] = timeAxisWithIncrement(data, fileSettings{3}.Value, beginning, ending, channel);
else
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
%Plot the channel
hold on
figure(channel)
plot(timeArray, yData);
ylabel(yAxis{channel}.Value);
xlabel(xAxis{channel}.Value);
title(channels{channel});
%Save plot
saveFigs('graph', figure(channel), channels(channel), path, fileSettings{1}.Value)
%reset
hold off;
close all;
end
end
end