Obslabel error when using biplot
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
desert_scientist90
el 5 de Feb. de 2020
Comentada: desert_scientist90
el 11 de Feb. de 2020
Hi I have a biplot with the PCA results from 9 houses and 14 variables. I am trying to label my scores with the correspondent chemical name. I am using the following code but matlab is giving me this error message. I already tried to transpose my cells and no luck. Any guidance will be appreciated.
Thanks
Z = zscore(spw); % Standardized data
[coefs,score,v,g,ex] = pca(Z);
vbls = {'1','2','3','4','5','6','7','8', '9'}; % Array of variable labels for houses
Pah={'Naph','2Methyl','1Methyl','Acy','Ace','Flu','Phe','Ant','Flt','Pyr','BaAnt', 'Chr', 'BbFlu','BkFLu','BePyr'};% chem names
h6 = biplot(coefs(:,1:2),'Scores',score(:,1:2),'ObsLabels',Pah, 'VarLabels', vbls);
Error using biplot (line 219)
'ObsLabels' value must be a character array, string array. or cell array of character vectors with one label
for each row of the 'Scores' matrix.
0 comentarios
Respuesta aceptada
Payas Bahade
el 11 de Feb. de 2020
Hi,
There seems to be a mismatch between number of Observation Labels (chemical names) and number of rows in ‘score’ matrix. Number of Observation Labels must be same as number of rows in ‘score’ matrix. In question it is mentioned that number of variables is 14, but ‘Pah’ has 15 labels. To avoid the mismatch please check the size of ‘score’ matrix and provide equal number of labels in ‘Pah’ variable.
Also, I created a sample ‘spw’ variable of size 15x9 with random numbers and tested in the code as provided by you. It seems to work fine.
spw = randn(15,9);%Random numbers
Z = zscore(spw); % Standardized data
[coefs,score,v,g,ex] = pca(Z);
vbls = {'1','2','3','4','5','6','7','8', '9'}; % Array of variable labels for houses
Pah={'Naph','2Methyl','1Methyl','Acy','Ace','Flu','Phe','Ant','Flt','Pyr','BaAnt', 'Chr', 'BbFlu','BkFLu','BePyr'};% chem names
h6 = biplot(coefs(:,1:2),'Scores',score(:,1:2),'ObsLabels',Pah, 'VarLabels', vbls);
Hope this helps!
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!