I have a table like this:
pic-table.jpg
I want to know that how I can remove the first, second and third smallest number from feature 3 (i.e. 3,3,6 in this example). I want to remove columns of these numbers from the table.
How can do it in matlab?

 Respuesta aceptada

madhan ravi
madhan ravi el 19 de En. de 2019
Editada: madhan ravi el 19 de En. de 2019
idx=sort(T{3,:}) % where T is your table
T(:,ismember(T{3,:},idx(1:3))) =[ ]

2 comentarios

Alireza Entezami
Alireza Entezami el 20 de En. de 2019
Thanks.
But the problem is that I don't want to transform my table to cell. The comments work on cell.
How I can work with table?
madhan ravi
madhan ravi el 20 de En. de 2019
Editada: madhan ravi el 20 de En. de 2019
Those commands work for table , there was no conversion made whatsoever see https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.html

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 19 de En. de 2019
NumSmallest = 3;
[~, idx] = mink(YourTable{3,2:end}, NumSmallest);
YourTable(:,idx+1) = [];
This presumes that the Feature1 Feature2 Feature3 are an actual column in the table, rather than being RowNames. If they are RowNames then
NumSmallest = 3;
[~, idx] = mink(YourTable{'Feature3',:}, NumSmallest);
YourTable(:,idx) = [];
You do not need to use a variable for NumSmallest: I used one here to clarify which 3 was the number of smallest to consider, and which 3 was the row number.

2 comentarios

Alireza Entezami
Alireza Entezami el 20 de En. de 2019
Thanks.
I encounter error in running the code.
But the problem is that I don't want to transform my table to cell. The comments work on cell.
How I can work with table?
Walter Roberson
Walter Roberson el 20 de En. de 2019
{} indexing is used for table() objects to access the items stored in the rows.
YourTable{3,2:end} would be a problem if not all of the columns starting from column 2 are numeric.
What error message are you getting?

Iniciar sesión para comentar.

Categorías

Preguntada:

el 19 de En. de 2019

Comentada:

el 20 de En. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by