From: MOOON MOOON on 24 Jun 2010 15:21 Hello, Could you please help me in this matter. Assume we have the following data: H_T=[36 66 21 65 52 67 73 ; 31 23 19 33 36 39 42 ] P=[40 38 39 40 35 32 37 ] I want to create new three matrices that have the following properties: the matrix H (the first part in matrix H_T) will be divided to 3 intervals matrix 1 : the 1st interval contains the H values between 20 to 40 matrix 2 : the 2nd interval contains the H values between 40 to 60 matrix 3 : the 3rd interval contains the H values between 60 to 80 the important thing is that the corresponding T and P also will be included in their new matrices meaning that H will control the new matrices depending on the specifications defined above. so, the resultant matrices will be: H_T_1=[36 21 ; 31 19] P_1=[40 39] H_T_2=[52 ; 36] P_2=[35] H_T_3=[66 65 67 73 ; 23 33 39 42] P_3=[38 40 32 37] Actually, this is a simple example and it is easy by looking to create the new matrices depending on the specifications, BUT in my values I have thousands of data which is very difficult to do that. Any help is highly appreciated. best regards.
From: us on 24 Jun 2010 15:42 "MOOON MOOON" <shaheed107(a)yahoo.com> wrote in message <i00b71$45o$1(a)fred.mathworks.com>... > > Hello, > > Could you please help me in this matter. > > Assume we have the following data: > > H_T=[36 66 21 65 52 67 73 ; 31 23 19 33 36 39 42 ] > > P=[40 38 39 40 35 32 37 ] > > I want to create new three matrices that have > the following properties: > > the matrix H (the first part in matrix H_T) will be divided to 3 intervals > > matrix 1 : the 1st interval contains the H values between 20 to 40 > matrix 2 : the 2nd interval contains the H values between 40 to 60 > matrix 3 : the 3rd interval contains the H values between 60 to 80 > > the important thing is that the corresponding T and P > also will be included in their new matrices meaning that H will > control the new matrices depending on the specifications defined above. > > so, the resultant matrices will be: > > H_T_1=[36 21 ; 31 19] > P_1=[40 39] > > > H_T_2=[52 ; 36] > P_2=[35] > > > H_T_3=[66 65 67 73 ; 23 33 39 42] > P_3=[38 40 32 37] > > Actually, this is a simple example and it is easy by looking > to create the new matrices depending on the specifications, > BUT in my values I have thousands of data which is very difficult > to do that. > > > Any help is highly appreciated. > best regards. one of the many solutions % the data m=[ 36 66 21 65 52 67 73 31 23 19 33 36 39 42 ]; v=[40 38 39 40 35 32 37]; iv=[ 20 40 40 60 60 80 ]; % the engine [ix,ix]=arrayfun(@(x,y) histc(m(1,:),x:y),iv(:,1),iv(:,2),'uni',false); r=cellfun(@(x) [m(:,x~=0);v(x~=0)],ix,'uni',false); % the result % - note: each CELL combines your two outputs; simply take them apart if necessary r{1} %{ 36 21 % <- HT_T_1 row 1 31 19 % <- HT_T_1 row 2 40 39 % <- P_1 %} us
From: MOOON MOOON on 24 Jun 2010 17:41 Thanks for your reply, but when I write the following function in MATLAB: [ix,ix]=arrayfun(@(x,y) histc(m(1,:),x:y),iv(:,1),iv(:,2),'uni',false); it gives me the following error: ??? Undefined command/function 'arrayfun'. Also, I searched for the function ( arrayfun ), but it is not found Any idea ? thanks
From: Steven Lord on 24 Jun 2010 17:58 "MOOON MOOON" <shaheed107(a)yahoo.com> wrote in message news:i00jdv$1e9$1(a)fred.mathworks.com... > > Thanks for your reply, > > but when I write the following function in MATLAB: > > [ix,ix]=arrayfun(@(x,y) histc(m(1,:),x:y),iv(:,1),iv(:,2),'uni',false); > > it gives me the following error: > > ??? Undefined command/function 'arrayfun'. > > Also, I searched for the function ( arrayfun ), but it is not found > > Any idea ? ARRAYFUN was introduced in MATLAB 7.1 (R14SP3). If you have an older version, you will not be able to use this function. http://www.mathworks.com/access/helpdesk/help/techdoc/rn/f30-1008061.html#f30-1008158 -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: MOOON MOOON on 24 Jun 2010 18:09 Unfortunately, I am using MATLAB 7.0 So, this function is not defined. But, is there another solution to my problem. regards
|
Next
|
Last
Pages: 1 2 Prev: merging matrices in loop Next: variable classification problems with parfor |