Skip to content

Commit

Permalink
Pca: fix bug for tables with less than four features
Browse files Browse the repository at this point in the history
  • Loading branch information
dlegland committed Dec 23, 2020
1 parent 0357b70 commit b02be7b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions matStats/@Pca/Pca.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
fileName = sprintf('%s-pca.cc12.png', obj.TableName);
print(h(1), fullfile(options.DirFigures, fileName), '-dpng');

if ishandle(h(2))
if length(h) > 1
fileName = sprintf('%s-pca.cc34.png', obj.TableName);
print(h(2), fullfile(options.DirFigures, fileName), '-dpng');
end
Expand Down Expand Up @@ -315,7 +315,7 @@ function savePcaResults(obj, dirResults)

% loading plots PC3-PC4
if npc >= 4
handles.loadingsPlot34 = figure;
handles.LoadingsPlot34 = figure;
loadingPlot(obj, 3, 4, 'showNames', options.ShowVarNames, options.AxesProperties{:});
end
end
Expand All @@ -327,22 +327,22 @@ function saveFigures(obj, handles, dirFigs)
fileName = sprintf('%s-pca.ev.png', baseName);
print(handles.ScreePlot, fullfile(dirFigs, fileName), '-dpng');

if isfield(handles, 'scorePlot12')
if isfield(handles, 'ScorePlot12')
fileName = sprintf('%s-pca.sc12.png', baseName);
print(handles.ScorePlot12, fullfile(dirFigs, fileName), '-dpng');
end

if isfield(handles, 'scorePlot34')
if isfield(handles, 'ScorePlot34')
fileName = sprintf('%s-pca.sc34.png', baseName);
print(handles.ScorePlot34, fullfile(dirFigs, fileName), '-dpng');
end

if isfield(handles, 'loadingsPlot12')
if isfield(handles, 'LoadingsPlot12')
fileName = sprintf('%s-pca.ld12.png', baseName);
print(handles.LoadingsPlot12, fullfile(dirFigs, fileName), '-dpng');
end

if isfield(handles, 'loadingsPlot34')
if isfield(handles, 'LoadingsPlot34')
fileName = sprintf('%s-pca.ld34.png', baseName);
print(handles.LoadingsPlot34, fullfile(dirFigs, fileName), '-dpng');
end
Expand Down Expand Up @@ -374,7 +374,7 @@ function saveFigures(obj, handles, dirFigs)
h2 = figure;
correlationCircle(obj, 3, 4, varargin{:});
else
h2 = -1;
h2 = [];
end

h = [h1 h2];
Expand Down

0 comments on commit b02be7b

Please sign in to comment.