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 件)

カテゴリ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by