Get data from a matrix

I have a matrix such as x0=[3.88,3.88,3.88,3.88,3.88,3.88,3.59,3.59,3.59,3.59,3.59,3.23,3.59,3.59,3.23,3.23,3.23,2.94,2.94,2.94,2.94,2.94,2.94,2.59,2.59,2.59,2.59,2.59,2.59,2.59,2.59,2.26,2.26,1.97,2.26,2.26,1.97,2.26,2.26,2.26,1.97,1.97,1.97,1.97,1.62,1.62,1.97,2.88,8.41,8.73,9.70,10.03,10.35,10.03,10.03,10.35,10.35,10.35,5.50,5.17,4.85,]; Qustion 1: How can I get data from x0 to determine whether this data are duplication and increasing? Qustion 2: n=length(x0); x1=x0(1:2:n); x2=x0(2:2:n); x3=x0(1:3:n); x4=x0(2:3:n); x5=x0(3:3:n); x6=x0(1:4:n); x7=x0(2:4:n); x8=x0(3:4:n); x9=x0(4:4:n); How to write a loop as "for...end" to get x1,x2,...

 채택된 답변

Paulo Silva
Paulo Silva 2011년 3월 22일

0 개 추천

if numel(x0)~=unique(x0)
disp('x0 got duplicated elements')
end
if all(diff(x0)>0)
disp('x0 is increasing')
end

댓글 수: 4

Tian Lin
Tian Lin 2011년 3월 22일
thanks,Paulo Silva,so,what about question 2?
Paulo Silva
Paulo Silva 2011년 3월 22일
put those x inside a cell, that way cell 1 can be x1, cell 2 x2...
Paulo Silva
Paulo Silva 2011년 3월 22일
x={x0(1:5),x0(5:10)}
Tian Lin
Tian Lin 2011년 3월 22일
thank you very much

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

추가 답변 (0개)

카테고리

제품

질문:

2011년 3월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by