how to sort data
이전 댓글 표시
I have two column of datas
COLUMN1 COLUMN2
5 R
3 E
1 A
4 P
i NEED THE OUTPUT AS
1 A
3 E
4 P
5 R
CAN ANYONE TELL HOW TO PROCESS PLEASE
댓글 수: 3
Jan
2011년 9월 15일
Pat, please explain the input and output more descriptive. Do you have an ASCII or Excel file with two columns, or a matrix with two columns, or two column vectors? Is the output a string, another file, some characters, different variables?
Take the time to read: http://www.mathworks.com/matlabcentral/answers/797-how-do-i-write-a-good-answer-for-matlab-answers
Jan
2011년 9월 15일
@Pat: If I'm looking on your other 30 questions, it seems, like you are not interested in answering questions for clarifications. Answering your questions would be much easier, if you take the time to explain all necessary details. Almost the half of your question do not get any answer, and you could accept two answers only. I recommended the standard usage of upper/lower-case characters before, but without impressing you.
If you do not use this forum for an efficient exchange of information, why do you use it at all?
Jan
2011년 9월 15일
@Pat: Now the format is much nicer to read.
채택된 답변
추가 답변 (1개)
Andrei Bobrov
2011년 9월 15일
data = reshape({5 'R' 3 'E' 1 'A' 4 'P'},2,[])'
out = sortrows(data,1)
or
out = reshape(sortrows(data,1)',1,[])
if
data(:,1)=cellfun(@num2str,data(:,1),'un',0)
out = sortrows(data,1)
댓글 수: 3
Jan
2011년 9월 15일
@Andrei: You are bold. +1
Pat
2011년 9월 15일
Andrei Bobrov
2011년 9월 15일
out = sortrows(data,-1)
카테고리
도움말 센터 및 File Exchange에서 Variables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!