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 @@
% window.
%
%fname = 'sampleLogFileWithMarker.txt';
fname = 'testies_v2.txt';
fname = '';
% PLOTTING SWITCHES - set them to 0 or 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
plot = 1; % to choose plotting
separatePlot = 1; % to generate separatePlots
separatePlot = 0; % to generate separatePlots
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)
% DATA TO PLOT %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -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
% will be plotted using seperatePlots.
%
separateData = {'PID_roll_vel'};
separateData = {'X pos PID_Correction', 'Altitude PID_Correction'};
% MULTIDATA
% 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
% will be plotted using multiPlots.
%
multiData = {};
multiData = {'X pos PID_Correction', 'Altitude PID_Correction'};
% SUBDATA
% 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
% will be plotted using subPlots.
%
subData = {};
subData = {'X pos PID_Correction', 'Altitude PID_Correction'};
% COLOR FOR PLOTTING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
color = 'r'; % one character for color 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
......@@ -92,12 +93,11 @@ expData = parse_log(params.file.pathName, params);
%% plotting routines %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% plot the data accoriding to the plotting parameters set
%
%
plot_data(expData, params.plotting);
%% creating the main structure to be stored in the workspace %%%%%%%%%%%%%
%
main.params = params;
main.expData = expData;
clearvars -except main;
save main main;
\ No newline at end of file
% main.params = params;
% main.expData = expData;
% clearvars -except main;
% save main main;
\ No newline at end of file
......@@ -43,6 +43,7 @@ identifier = string(1);
if (regexp(identifier,'%'))
foundHeaders = 1;
% this is a line of headers; extract headers:
string = strrep(string,' ', '_');
headers = strsplit(string);
headers{1} = strrep(headers{1},'%', '');
numOfHeaders = length(headers);
......@@ -126,17 +127,20 @@ if exist('params', 'var')
end
else
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;']);
end
end
else
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;']);
end
end
else
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;']);
end
end
......@@ -150,11 +154,13 @@ if exist('params', 'var')
end
else
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;']);
end
end
else
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;']);
end
end
......@@ -167,6 +173,7 @@ if exist('params', 'var')
end
else
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;']);
end
end
......
......@@ -6,6 +6,8 @@ function plot_data(expData, plotParams)
% check plotting switch
if (~plotParams.plot)
disp('No plotting');
elseif(~plotParams.multiPlot && ~plotParams.subPlot && ~plotParams.separatePlot)
disp('No plotting, select a plotting style');
else
%% check separate plotting switch
if(plotParams.separatePlot)
......@@ -74,7 +76,7 @@ else
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.separateData)) % if no headers mentioned for separate plotting, use all of the headers
headers = fieldNames(expData);
headers = fieldnames(expData);
else
headers = plotParams.separateData;
end
......
......@@ -13,6 +13,7 @@ function plot_multi(expData, useMarker, varargin)
numOfHeaders = 0;
headers = {};
for i = 1:length(varargin)
varargin{i} = strrep(varargin{i},' ', '_');
if(~isPlotCharString(varargin{i}))
numOfHeaders = numOfHeaders + 1;
headers{numOfHeaders} = varargin{i};
......@@ -144,13 +145,15 @@ for i = 1:numOfHeaders
end
end
ylabel(yAxisLabel);
ylabel(yAxisLabel,'Interpreter', 'none');
% constructing statement for inserting the legend
legendString = ['legend('''];
legendString = ['legend('];
for i = 1: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
legendString = strcat(legendString,headers{i},''',''');
end
......
......@@ -25,6 +25,7 @@ end
% bulding the plot statement that will be executed
for i = 1:length(varargin)
varargin{i} = strrep(varargin{i},' ', '_');
dataHeader = varargin{i};
% continue to next iteration if current argument is a plotting character string
......@@ -49,19 +50,19 @@ for i = 1:length(varargin)
plotCharString = buildPlotCharString(eval(['expData.' dataHeader '.params']));
plotString = strcat(plotString,',''', plotCharString, ''');');
end
% plotting data and making it look good
figure;
whitebg(gcf,eval(['expData.' dataHeader '.params.backgnd'])); % setting background
eval(plotString); % plotting
title(dataHeader); % setting title
title(dataHeader, 'Interpreter', 'none'); % setting title
xlabel(['Time (' time.unit ')']); % setting the x-axis label
if(eval(['isempty(expData.' dataHeader '.unit)']))
yAxisLabel = dataHeader;
else
yAxisLabel = [dataHeader ' (' eval(['expData.' dataHeader '.unit']) ')'];
end
ylabel(yAxisLabel); % setting y-axis label
ylabel(yAxisLabel,'Interpreter', 'none'); % setting y-axis label
xlim([0, time.data(end)]); % setting x-axis limits
grid ON; % setting grid lines on the graph
% adding markers
......
......@@ -41,6 +41,8 @@ for i = 1:length(varargin)
continue;
end
varargin{i} = strrep(varargin{i},' ', '_');
% keeping track of the number of headers
currHeaderIndex = currHeaderIndex + 1;
......@@ -75,14 +77,14 @@ for i = 1:length(varargin)
%% plotting data and making it look pretty
eval(plotString);
title(varargin{i});
title(varargin{i},'Interpreter','none');
xlabel(['Time (' time.unit ')']);
if(eval(['isempty(expData.' varargin{i} '.unit)']))
yAxisLabel = varargin{i};
else
yAxisLabel = [varargin{i} ' (' eval(['expData.' varargin{i} '.unit']) ')'];
end
ylabel(yAxisLabel);
ylabel(yAxisLabel,'Interpreter','none');
xlim([0,time.data(end)]);
grid ON;
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