Biplot label error after following matlab help guide

조회 수: 8 (최근 30일)
Hi I am trying to display the results of my PCA analysis on a biplot by following the example on https://www.mathworks.com/help/stats/biplot.html . I want to add the labels to the lines and scores. After I created hid to label my houses on the graph I get the following error message:
VarLabels' value must be a string array, a character array, or a cell array of character vectors with one ↑
Error: Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or
other syntax error. To construct matrices, use brackets instead of parentheses.
>>
Is there source that I can refer to to fix this issue and also add the labels on the scores display as dots? Thanks in advance for your help
biplot(coefs(:,1:2)),'Score',score(:,1:2); %% graph step
hid = {'House1','House2','House3','House4','House5','House6','House7','House8' 'House9'}; % Array of variable labels for lines on the graphs
h = biplot(coefs(:,1:2),'Scores',score(:,1:2),...
'Color', 'b', 'Marker', 'o', 'VarLabels', hid);

채택된 답변

Sahithi Kanumarlapudi
Sahithi Kanumarlapudi 2020년 2월 7일
Hi,
VarLabels must be a vector with one label for each row of the coefficients matrix. Error will be raised if the number of labels is greater or less than the rows in the coefficient matrix. Make sure of this. Error might note be because of the data in cell array.
And in your command, you have to use ‘Scores’ instead of ‘Score’.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by