Hi, I have following code:
a_x = 1.5:0.2:a_max;
a_y = 1.5:0.2:a_max;
a = zeros(length(a_x),length(a_y));
for i = 1:length(a_x)
for j = 1:length(a_y)
a(j,i) = (a_x(i)+a_y(j))/2;
end
end
I would like to remove all duplicate values in a, and turn this in a vector with ascending value. Any idea how?

 채택된 답변

KL
KL 2017년 10월 5일
편집: KL 2017년 10월 5일

0 개 추천

unique(a) %EDITED

댓글 수: 3

Guillaume
Guillaume 2017년 10월 5일
unique already return the values sorted (unless the 'stable' option is used), so the sort is redundant.
KL
KL 2017년 10월 5일
Ah, Thanks Guillaume . Edited!
thestargazer
thestargazer 2017년 10월 5일
Thanks!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

질문:

2017년 10월 5일

댓글:

2017년 10월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by