Hello,
I'm trying to preform PCA analysis for a set of values that I get from the attached excel.
I need to preform the analysis on all 40 variables.
clc
clear all
close all
x=readtable('PCA table.xlsx');
x=table2array(x);
mapcaplot(x)
When I try to use mapcaplot I get the following error:
Index in position 2 exceeds array bounds (must not exceed 1).
Error in mapcaplot>localUpdateBrushPlots (line 201)
ydata = data(:,INDEX_DIM2);
Error in mapcaplot>localInit (line 178)
localUpdateBrushPlots(fig);
Error in mapcaplot (line 65)
localInit(fig,varargin{:});
Error in Untitled (line 7)
mapcaplot(x)
I would appreciate some help. I've never tried to do PCA before and I'm not sure what exactly the function needs as input.
Thank you,
Ruth

댓글 수: 1

Star Strider
Star Strider 2021년 9월 9일
If you use the rmmissing funciton on ‘x’, only two rows of valid data remain.

댓글을 달려면 로그인하십시오.

 채택된 답변

Adam Danz
Adam Danz 2021년 9월 9일

0 개 추천

See the documentation.
The data input should be a numeric array or a DataMatrix object. Yours is a table.
Also see table2array.

댓글 수: 5

Ruth Pikovsky
Ruth Pikovsky 2021년 9월 9일
Hi, thanks for the answer. I did use table2array in my code.
Adam Danz
Adam Danz 2021년 9월 9일
편집: Adam Danz 2021년 9월 9일
Sorry, I missed that. The renaming of x threw me off.
The NaN values in your data are the problem (as Star Strider indicated). mapcaplot calls pca() which removes observations with NaN values which results in losing entire rows of data that contain one or more NaN values.
I recommend cleaning up your data, specifically, filling the missing values, if possible.
Ruth Pikovsky
Ruth Pikovsky 2021년 9월 9일
Thank you, the function works now. I'll try to figure out if I can replace the missing NaN values with zeroes.
Adam Danz
Adam Danz 2021년 9월 9일
That will likely affect the pca results, though. Try interpolation if that makes sense for the data.
Ruth Pikovsky
Ruth Pikovsky 2021년 9월 10일
Yeah that's also a good idea. Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

제품

릴리스

R2020a

태그

질문:

2021년 9월 9일

댓글:

2021년 9월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by