Sortrows works in my main function but doesn't work in my callback function?

조회 수: 4 (최근 30일)
Hi,
I'm using sortrows to sort a dataset array based on a column that contains non scalar values
NaN 51.1512 4.0000 6.0000
NaN 80.7646 3.0000 6.0000
NaN 89.3755 2.0000 6.0000
NaN 96.3119 1.0000 6.0000
NaN 51.1512 8.0000 5.0000
NaN 80.7646 7.0000 5.0000
5.1104 89.3755 6.0000 5.0000
NaN 96.3119 5.0000 5.0000
9.0177 51.1512 12.0000 4.0000
NaN 80.7646 11.0000 4.0000
5.3294 89.3755 10.0000 4.0000
When i use sortrows in my main function, it works but when i use it in my callback functions i get the error,
Some cells in X contain non-scalar values and cannot be sorted.
Error in sortrows (line 87)
ndx = sort_cell_back_to_front(x_sub, col);
Error in ScatterPlot (line 28)
sortData = sortrows(sortData,3);
Why does this happen?

채택된 답변

Walter Roberson
Walter Roberson 2016년 6월 24일
You did not indicate which values you are sorting inside the callback. If you are fetching values from a uitable where the user has edited an entry, then the entry might have become a string without you realizing it, and strings are not scalar values.
  댓글 수: 2
Soumyatha Gavvala
Soumyatha Gavvala 2016년 6월 24일
I have specified my array sortData and the column number 3 inside my callback function.
sortData = sortrows(sortData,3);
Soumyatha Gavvala
Soumyatha Gavvala 2016년 6월 24일
Thanks I figured it out, my callback function was reading the cell arrays by a cell each column rather than the array. Fixed it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by