Skip to content
Snippets Groups Projects
Commit c81acb9c authored by Andy Snawerdt's avatar Andy Snawerdt
Browse files

Updated analysis tools to handle spaces in header files and properly format...

Updated analysis tools to handle spaces in header files and properly format axis, titles, and legends
parent 81593831
No related branches found
No related tags found
No related merge requests found
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
% window. % window.
% %
%fname = 'sampleLogFileWithMarker.txt'; %fname = 'sampleLogFileWithMarker.txt';
fname = 'testies_v2.txt'; fname = '';
% PLOTTING SWITCHES - set them to 0 or 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % PLOTTING SWITCHES - set them to 0 or 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
plot = 1; % to choose plotting plot = 1; % to choose plotting
separatePlot = 1; % to generate separatePlots separatePlot = 0; % to generate separatePlots
multiPlot = 1; % to generate multiPlot multiPlot = 1; % to generate multiPlot
subPlot = 0; % to generate subPlots subPlot = 1; % to generate subPlots
clearFigs = 0; % to close all the plots (needed only by the GUI) clearFigs = 0; % to close all the plots (needed only by the GUI)
% DATA TO PLOT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % DATA TO PLOT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
...@@ -25,27 +25,28 @@ clearFigs = 0; % to close all the plots (needed only by the GUI) ...@@ -25,27 +25,28 @@ clearFigs = 0; % to close all the plots (needed only by the GUI)
% seperatePlots. If this is empty but "plot" switch is 1, all the columns % seperatePlots. If this is empty but "plot" switch is 1, all the columns
% will be plotted using seperatePlots. % will be plotted using seperatePlots.
% %
separateData = {'PID_roll_vel'}; separateData = {'X pos PID_Correction', 'Altitude PID_Correction'};
% MULTIDATA % MULTIDATA
% write names of the data headers that you want to plot using multiPlots. % write names of the data headers that you want to plot using multiPlots.
% If this is empty but "plot" switch is 1, the data headers in separateData % If this is empty but "plot" switch is 1, the data headers in separateData
% will be plotted using multiPlots. % will be plotted using multiPlots.
% %
multiData = {}; multiData = {'X pos PID_Correction', 'Altitude PID_Correction'};
% SUBDATA % SUBDATA
% write names of the data headers that you want to plot using subPlots. % write names of the data headers that you want to plot using subPlots.
% If this is empty but "plot" switch is 1, the data headers in multiData % If this is empty but "plot" switch is 1, the data headers in multiData
% will be plotted using subPlots. % will be plotted using subPlots.
% %
subData = {}; subData = {'X pos PID_Correction', 'Altitude PID_Correction'};
% COLOR FOR PLOTTING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % COLOR FOR PLOTTING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
color = 'r'; % one character for color of the plotting line color = 'r'; % one character for color of the plotting line
marker = ''; % one character for the marker of the plotting line marker = ''; % one character for the marker of the plotting line
style = ':'; % one character for the style of the plotting line style = '-'; % one character for the style of the plotting line
backgnd = [1 1 1]; % rgb array for background color of the plot backgnd = [1 1 1]; % rgb array for background color of the plot
...@@ -92,12 +93,11 @@ expData = parse_log(params.file.pathName, params); ...@@ -92,12 +93,11 @@ expData = parse_log(params.file.pathName, params);
%% plotting routines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% plotting routines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plot the data accoriding to the plotting parameters set % plot the data accoriding to the plotting parameters set
% %
plot_data(expData, params.plotting); plot_data(expData, params.plotting);
%% creating the main structure to be stored in the workspace %%%%%%%%%%%%% %% creating the main structure to be stored in the workspace %%%%%%%%%%%%%
% %
main.params = params; % main.params = params;
main.expData = expData; % main.expData = expData;
clearvars -except main; % clearvars -except main;
save main main; % save main main;
\ No newline at end of file \ No newline at end of file
...@@ -43,6 +43,7 @@ identifier = string(1); ...@@ -43,6 +43,7 @@ identifier = string(1);
if (regexp(identifier,'%')) if (regexp(identifier,'%'))
foundHeaders = 1; foundHeaders = 1;
% this is a line of headers; extract headers: % this is a line of headers; extract headers:
string = strrep(string,' ', '_');
headers = strsplit(string); headers = strsplit(string);
headers{1} = strrep(headers{1},'%', ''); headers{1} = strrep(headers{1},'%', '');
numOfHeaders = length(headers); numOfHeaders = length(headers);
...@@ -126,17 +127,20 @@ if exist('params', 'var') ...@@ -126,17 +127,20 @@ if exist('params', 'var')
end end
else else
for i = 1:length(params.plotting.separateData) for i = 1:length(params.plotting.separateData)
params.plotting.separateData{i} = strrep(params.plotting.separateData{i},' ', '_');
eval(['loggedData.' params.plotting.separateData{i} '.params.plot = 1;']); eval(['loggedData.' params.plotting.separateData{i} '.params.plot = 1;']);
end end
end end
else else
for i = 1:length(params.plotting.multiData) for i = 1:length(params.plotting.multiData)
params.plotting.multiData{i} = strrep(params.plotting.multiData{i},' ', '_');
eval(['loggedData.' params.plotting.multiData{i} '.params.plot = 1;']); eval(['loggedData.' params.plotting.multiData{i} '.params.plot = 1;']);
end end
end end
else else
for i = 1:length(params.plotting.subData) for i = 1:length(params.plotting.subData)
params.plotting.subData{i} = strrep(params.plotting.subData{i},' ', '_');
eval(['loggedData.' params.plotting.subData{i} '.params.plot = 1;']); eval(['loggedData.' params.plotting.subData{i} '.params.plot = 1;']);
end end
end end
...@@ -150,11 +154,13 @@ if exist('params', 'var') ...@@ -150,11 +154,13 @@ if exist('params', 'var')
end end
else else
for i = 1:length(params.plotting.separateData) for i = 1:length(params.plotting.separateData)
params.plotting.separateData{i} = strrep(params.plotting.separateData{i},' ', '_');
eval(['loggedData.' params.plotting.separateData{i} '.params.plot = 1;']); eval(['loggedData.' params.plotting.separateData{i} '.params.plot = 1;']);
end end
end end
else else
for i = 1:length(params.plotting.multiData) for i = 1:length(params.plotting.multiData)
params.plotting.multiData{i} = strrep(params.plotting.multiData{i},' ', '_');
eval(['loggedData.' params.plotting.multiData{i} '.params.plot = 1;']); eval(['loggedData.' params.plotting.multiData{i} '.params.plot = 1;']);
end end
end end
...@@ -167,6 +173,7 @@ if exist('params', 'var') ...@@ -167,6 +173,7 @@ if exist('params', 'var')
end end
else else
for i = 1:length(params.plotting.separateData) for i = 1:length(params.plotting.separateData)
params.plotting.separateData{i} = strrep(params.plotting.separateData{i},' ', '_');
eval(['loggedData.' params.plotting.separateData{i} '.params.plot = 1;']); eval(['loggedData.' params.plotting.separateData{i} '.params.plot = 1;']);
end end
end end
......
...@@ -6,6 +6,8 @@ function plot_data(expData, plotParams) ...@@ -6,6 +6,8 @@ function plot_data(expData, plotParams)
% check plotting switch % check plotting switch
if (~plotParams.plot) if (~plotParams.plot)
disp('No plotting'); disp('No plotting');
elseif(~plotParams.multiPlot && ~plotParams.subPlot && ~plotParams.separatePlot)
disp('No plotting, select a plotting style');
else else
%% check separate plotting switch %% check separate plotting switch
if(plotParams.separatePlot) if(plotParams.separatePlot)
...@@ -74,7 +76,7 @@ else ...@@ -74,7 +76,7 @@ else
if(isempty(plotParams.subData)) % if none mentioned, use headers mentioned for multi plotting if(isempty(plotParams.subData)) % if none mentioned, use headers mentioned for multi plotting
if(isempty(plotParams.multiData)) % if no headers mentioned for multi plotting, use headers mentioned for separate plotting if(isempty(plotParams.multiData)) % if no headers mentioned for multi plotting, use headers mentioned for separate plotting
if(isempty(plotParams.separateData)) % if no headers mentioned for separate plotting, use all of the headers if(isempty(plotParams.separateData)) % if no headers mentioned for separate plotting, use all of the headers
headers = fieldNames(expData); headers = fieldnames(expData);
else else
headers = plotParams.separateData; headers = plotParams.separateData;
end end
......
...@@ -13,6 +13,7 @@ function plot_multi(expData, useMarker, varargin) ...@@ -13,6 +13,7 @@ function plot_multi(expData, useMarker, varargin)
numOfHeaders = 0; numOfHeaders = 0;
headers = {}; headers = {};
for i = 1:length(varargin) for i = 1:length(varargin)
varargin{i} = strrep(varargin{i},' ', '_');
if(~isPlotCharString(varargin{i})) if(~isPlotCharString(varargin{i}))
numOfHeaders = numOfHeaders + 1; numOfHeaders = numOfHeaders + 1;
headers{numOfHeaders} = varargin{i}; headers{numOfHeaders} = varargin{i};
...@@ -144,13 +145,15 @@ for i = 1:numOfHeaders ...@@ -144,13 +145,15 @@ for i = 1:numOfHeaders
end end
end end
ylabel(yAxisLabel); ylabel(yAxisLabel,'Interpreter', 'none');
% constructing statement for inserting the legend % constructing statement for inserting the legend
legendString = ['legend(''']; legendString = ['legend('];
for i = 1:numOfHeaders for i = 1:numOfHeaders
if(i == numOfHeaders) if(i == numOfHeaders)
legendString = strcat(legendString,headers{i},''',''Location'',''NorthWest'');'); legendString = strcat(legendString,headers{i},'''}',',''Interpreter'',''none'',''Location'',''NorthWest'');');
elseif(i == 1)
legendString = strcat(legendString,'{''',headers{i},''',''');
else else
legendString = strcat(legendString,headers{i},''','''); legendString = strcat(legendString,headers{i},''',''');
end end
......
...@@ -25,6 +25,7 @@ end ...@@ -25,6 +25,7 @@ end
% bulding the plot statement that will be executed % bulding the plot statement that will be executed
for i = 1:length(varargin) for i = 1:length(varargin)
varargin{i} = strrep(varargin{i},' ', '_');
dataHeader = varargin{i}; dataHeader = varargin{i};
% continue to next iteration if current argument is a plotting character string % continue to next iteration if current argument is a plotting character string
...@@ -49,19 +50,19 @@ for i = 1:length(varargin) ...@@ -49,19 +50,19 @@ for i = 1:length(varargin)
plotCharString = buildPlotCharString(eval(['expData.' dataHeader '.params'])); plotCharString = buildPlotCharString(eval(['expData.' dataHeader '.params']));
plotString = strcat(plotString,',''', plotCharString, ''');'); plotString = strcat(plotString,',''', plotCharString, ''');');
end end
% plotting data and making it look good % plotting data and making it look good
figure; figure;
whitebg(gcf,eval(['expData.' dataHeader '.params.backgnd'])); % setting background whitebg(gcf,eval(['expData.' dataHeader '.params.backgnd'])); % setting background
eval(plotString); % plotting eval(plotString); % plotting
title(dataHeader); % setting title title(dataHeader, 'Interpreter', 'none'); % setting title
xlabel(['Time (' time.unit ')']); % setting the x-axis label xlabel(['Time (' time.unit ')']); % setting the x-axis label
if(eval(['isempty(expData.' dataHeader '.unit)'])) if(eval(['isempty(expData.' dataHeader '.unit)']))
yAxisLabel = dataHeader; yAxisLabel = dataHeader;
else else
yAxisLabel = [dataHeader ' (' eval(['expData.' dataHeader '.unit']) ')']; yAxisLabel = [dataHeader ' (' eval(['expData.' dataHeader '.unit']) ')'];
end end
ylabel(yAxisLabel); % setting y-axis label ylabel(yAxisLabel,'Interpreter', 'none'); % setting y-axis label
xlim([0, time.data(end)]); % setting x-axis limits xlim([0, time.data(end)]); % setting x-axis limits
grid ON; % setting grid lines on the graph grid ON; % setting grid lines on the graph
% adding markers % adding markers
......
...@@ -41,6 +41,8 @@ for i = 1:length(varargin) ...@@ -41,6 +41,8 @@ for i = 1:length(varargin)
continue; continue;
end end
varargin{i} = strrep(varargin{i},' ', '_');
% keeping track of the number of headers % keeping track of the number of headers
currHeaderIndex = currHeaderIndex + 1; currHeaderIndex = currHeaderIndex + 1;
...@@ -75,14 +77,14 @@ for i = 1:length(varargin) ...@@ -75,14 +77,14 @@ for i = 1:length(varargin)
%% plotting data and making it look pretty %% plotting data and making it look pretty
eval(plotString); eval(plotString);
title(varargin{i}); title(varargin{i},'Interpreter','none');
xlabel(['Time (' time.unit ')']); xlabel(['Time (' time.unit ')']);
if(eval(['isempty(expData.' varargin{i} '.unit)'])) if(eval(['isempty(expData.' varargin{i} '.unit)']))
yAxisLabel = varargin{i}; yAxisLabel = varargin{i};
else else
yAxisLabel = [varargin{i} ' (' eval(['expData.' varargin{i} '.unit']) ')']; yAxisLabel = [varargin{i} ' (' eval(['expData.' varargin{i} '.unit']) ')'];
end end
ylabel(yAxisLabel); ylabel(yAxisLabel,'Interpreter','none');
xlim([0,time.data(end)]); xlim([0,time.data(end)]);
grid ON; grid ON;
set(gca,'Color',eval(['expData.' varargin{i} '.params.backgnd'])); set(gca,'Color',eval(['expData.' varargin{i} '.params.backgnd']));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment