Hi Alayt,
The “attribs” array contains only 3 elements while the code is accessing 60th element. This gives rise to the “Index exceeds the number of array elements” error.
In MATLAB there are many ways to access array elements based on their location. The location of an element in the array is known as “index”. The code given in the question uses “linear indexing” which means accessing array elements using a single index.
You can consider following the below link to learn more about Array Indexing in MATLAB:
“attribs(i)” corresponds to the element at the position “i” in “attribs”. In the code, “attribs(60)” means element at 60th position in the “attribs” array. But attribs has only 3 elements. Thus, the index which you are trying to access is “out of bounds”. So, to create clusters from columns 60, 61 and 62, use “attribs = [61,62,63]” but make the following change in your code
plot3(A_train(q,attribs(1)),A_train(q,attribs(2)),A_train(q,attribs(3)),colstyle{j})
xlabel(all_factors(attribs(1)));
ylabel(all_factors(attribs(2)));
zlabel(all_factors(attribs(3)));
Now, “attribs(1)” would correspond to 60 and so on. This will resolve the “out of index” error and plot the desired output.
