フィルターのクリア

Sorting of table except first ROW

5 ビュー (過去 30 日間)
Suraj
Suraj 2024 年 4 月 30 日
回答済み: Prateekshya 2024 年 4 月 30 日
I have one table
table = uitable(fig, 'Data', tableData, 'ColumnName', columnNames, 'ColumnEditable', true, ...
'Position', [17, 50, 870, 400], 'CellSelectionCallback', @(src, event) tableCellSelectionCallback(event), 'SelectionType', 'row', 'RowName', '','RowStriping','off','ColumnSortable',true);
this i have "ColumnSortable = true" which provide me a sorting in my table. but i want to execlude first row of table from this sorting can i do that..?
or do we have any call back when sort button is hit on ui...?

回答 (1 件)

Prateekshya
Prateekshya 2024 年 4 月 30 日
Hello Suraj,
I understand that you want to sort the table column wise excluding the first row of the table.
The closest workaround is to create a custom sort mechanism to separate the data out and perform sorting on the rows excluding the first row.
Here is an example on how to do it:
% Extract the first row
firstRow = table(1,:);
% Extract the rest of the data excluding the first row
restOfData = table(2:end,:);
% Perform sorting on restOfData
% Combine the first row back with the sorted data
sortedTableData = [firstRow; sortedData];
% Update the table's data
set(table, 'Data', sortedTableData);
Here you can perform the same sorting mechanism on the "restOfData" instead of the entire table.
I hope this helps!

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by