0

I have used TSNE in MATLAB for dimensionality reduction of a large data. I have been able to generate the Scatter Plot for TSNE in 2 dimensions which shows the labels of the cluster in different colors for each label, but, I am unable to do so in 3D. Referring to https://uk.mathworks.com/help/stats/tsne.html, I used the following syntax:- Where, merged_data_all is a 21392x1974 table with the last column named FunctionalGroup containing different labels (similar to the Fisheriris species labels in the Mathworks example on tsne). Y2 is the 3 dimensional variable which I have been successfully able to generate of dimensions 21392 x 3 double.

figure
v = double(categorical(merged_data_all.FunctionalGroup));
c = full(sparse(1:numel(v),v,ones(size(v)),numel(v),3));
scatter3(Y2(:,1),Y2(:,2),Y2(:,3),15,c,'filled')
title('3-D Embedding')
view(-50,8)

When I use this code, I get the error "Error using sparse- Index exceeds array bounds". I even tried to use a modified version of the code and doing something like this

scatter3(Y(:,1), Y(:,2),Y(:,3),merged_data_all.FunctionalGroup)

In case of this, I get the error "Error using scatter3- Input arguments must be numeric, datetime or categorical". I am quite confused as to how I can plot a 3d scatter plot, with 14 different colors (for the 14 types of different labels I have in my FunctionalGroup column of merged_data_all). Any help in this regard would be highly appreciated. Thanks

JChat
  • 784
  • 2
  • 13
  • 33
  • Which line does that error appear on? That is the important info – Ander Biguri Dec 06 '18 at 22:47
  • In the first code segment, it appears on the third line, as is evident that sparse() is used there. And for the second code segment, its only one line of code. So basically, the sparse() line is leading to the error. Thanks. – JChat Dec 06 '18 at 23:02
  • 1
    We do not have the data, so if `Y` was sparse and of bad size, this error could have been somewhere else. It is not evident where it is. [edit] your question with the entire error code, including the line, please – Ander Biguri Dec 06 '18 at 23:34

0 Answers0