Question

I'm working with k-means and silhouette in MATLAB GUI. On my MATLAB GUI, there is some push buttons, let us call it 'k-means' and 'silhouette'.

This is the code for the k-means:

[g c] = kmeans(data,k,'dist','SqEuclidean');

y = [data g];

t=uitable;

set(t,'Data',y) %this line will show the table in figure tab

And this is the code for silhouette:

[s,h]=silhouette(data,g,'SqEuclidean');

It works perfectly fine. The silhouette function shows the graphic in figure tab. However, I want to create the table version, too, to see the silhouette value for each row. This is the code I've written:

[s,h]=silhouette(data,g,'SqEuclidean');

z = [data s]

t = uitable;

set(t,'Data',z);

It works but it looks like this:

problem1

I want the graphic and table shown in different figure tab.

I have tried add some thing like hold on, so my code was like this:

[s,h]=silhouette(data,g,'SqEuclidean');
  z = [data s]
  figure, hold on
  t = uitable;
  set(t,'Data',z);

And it is shown like this:

problem2

Almost works. But I want the FIGURE 3's background is clear, so there is only table in it.

Any idea how to solve this?

Était-ce utile?

La solution

You can get what you want just by removing hold on.

If you'd rather have both the plot and the table in the same figure next to each other, you can adjust the position of the table like this:

set(t, 'Position', [left bottom width height])
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top