I have 2 columns of data imported from textscan. The data looks like this: U undetect and D detects
mydata=
.51 U
.57 D
.48 U
.47 D
my data = [4x1 double] [4x1 char]
I want to sort the data by the first column, and so the data will look like this:
.47 D
.48 U
.51 U
.57 D
I would like to save the cell structure so that the following command to assign a boolean value is saved:
c = zeros(size(mydata,1),1); % preallocate empty matrix
c = mydata{2} == 'U';
for i = 1:size(mydata,1)
curValue = mydata{i,2};
data{i,3} = ~isempty(curValue) && ischar(curValue) && strcmp(curValue ,'U');
end
I read about sorts, but the function is used to sort a matrix containing only numbers.
Does anyone have a solution for sorting arrays with a mixture of numbers and characters.
source
share