From: Bruno Luong on 20 Apr 2010 02:23 You can use this tool on FEX http://www.mathworks.com/matlabcentral/fileexchange/24255-consecutive-vector-spliter to accomplish the task: >> a = [1 2 3 4 5 10 15 20 21 22 23 24 30 37 40] a = 1 2 3 4 5 10 15 20 21 22 23 24 30 37 40 >> [c l] = SplitVec(a,'cons','split','length') % Fex tool c = [1x5 double] [10] [15] [1x5 double] [30] [37] [40] l = 5 1 1 5 1 1 1 >> c{l>1} select only the sequences more than 1 elements ans = 1 2 3 4 5 ans = 20 21 22 23 24 % Bruno
From: Gumah on 20 Apr 2010 03:07 On Apr 20, 2:23 pm, "Bruno Luong" <b.lu...(a)fogale.findmycountry> wrote: > You can use this tool on FEXhttp://www.mathworks.com/matlabcentral/fileexchange/24255-consecutive...to accomplish the task: > > >> a = [1 2 3 4 5 10 15 20 21 22 23 24 30 37 40] > > a = > > 1 2 3 4 5 10 15 20 21 22 23 24 30 37 40 > > >> [c l] = SplitVec(a,'cons','split','length') % Fex tool > > c = > > [1x5 double] [10] [15] [1x5 double] [30] [37] [40] > > l = > > 5 > 1 > 1 > 5 > 1 > 1 > 1 > > >> c{l>1} select only the sequences more than 1 elements > > ans = > > 1 2 3 4 5 > > ans = > > 20 21 22 23 24 > > % Bruno Thanks Bruno your help is highly appreciated
From: Gumah on 20 Apr 2010 06:03 On Apr 20, 2:23 pm, "Bruno Luong" <b.lu...(a)fogale.findmycountry> wrote: > You can use this tool on FEXhttp://www.mathworks.com/matlabcentral/fileexchange/24255-consecutive...to accomplish the task: > > >> a = [1 2 3 4 5 10 15 20 21 22 23 24 30 37 40] > > a = > > 1 2 3 4 5 10 15 20 21 22 23 24 30 37 40 > > >> [c l] = SplitVec(a,'cons','split','length') % Fex tool > > c = > > [1x5 double] [10] [15] [1x5 double] [30] [37] [40] > > l = > > 5 > 1 > 1 > 5 > 1 > 1 > 1 > > >> c{l>1} select only the sequences more than 1 elements > > ans = > > 1 2 3 4 5 > > ans = > > 20 21 22 23 24 > > % Bruno Just 1 more question.. how to number the answer like: ans(1) = 1 2 3 4 5 ans(2)= 20 21 22 23 24
From: Bruno Luong on 20 Apr 2010 06:16 > > Just 1 more question.. how to number the answer like: > > ans(1) = > > 1 2 3 4 5 > > ans(2)= > > 20 21 22 23 24 Store in cell: list = c(l>1) list{1} list{2} Bruno
From: Gumah on 20 Apr 2010 10:32
On Apr 20, 6:16 pm, "Bruno Luong" <b.lu...(a)fogale.findmycountry> wrote: > > Just 1 more question.. how to number the answer like: > > > ans(1) = > > > 1 2 3 4 5 > > > ans(2)= > > > 20 21 22 23 24 > > Store in cell: > > list = c(l>1) > > list{1} > list{2} > > Bruno Hi Bruno.. now I have this code for i=1 : n a= length(list{i}); v(i) = a; end C1=max(v) C2=min(v) C3=mean(v) I put all the answers in a victor in order to get the max, min and mean ..but I got this error ??? Index exceeds matrix dimensions. Error in ==> Untitled4 at 26 C1=max(v) I dont know what is wrong.. |