From: Mano Samuel on 11 May 2010 21:20 Hello, I have a variable x, x x(:,:,1) = {1x1 cell} x(:,:,2) = {1x1 cell} x(:,:,3) = {1x1 cell} x(:,:,4) = {1x1 cell} I would like to convert it and assign it to another variable 'data' as follows, data data(:,:,1) = [12x10 double] data(:,:,2) = [12x6 double] data(:,:,3) = [12x8 double] data(:,:,4) = [12x7 double] I am currently getting it done with the help of a FOR loop. is there a way to get the same done avoiding the FOR loop. x{:} , provides me with the desired value , but i'm not able to assign each individual cell to data without the help of a FOR loop. Hoping someone can help me out. Thank you.
From: us on 11 May 2010 21:51 "Mano Samuel" <manosamuel(a)rediffmail.com> wrote in message <hscvo5$1sn$1(a)fred.mathworks.com>... > > Hello, > I have a variable x, > x > x(:,:,1) = > {1x1 cell} > x(:,:,2) = > {1x1 cell} > x(:,:,3) = > {1x1 cell} > x(:,:,4) = > {1x1 cell} > I would like to convert it and assign it to another variable 'data' as follows, > data > data(:,:,1) = > [12x10 double] > data(:,:,2) = > [12x6 double] > data(:,:,3) = > [12x8 double] > data(:,:,4) = > [12x7 double] > I am currently getting it done with the help of a FOR loop. is there a way to get the same done avoiding the FOR loop. > > x{:} , provides me with the desired value , but i'm not able to assign each individual cell to data without the help of a FOR loop. Hoping someone can help me out. > Thank you. one of the solutions clear c d; % <- save old stuff! c{:,:,1}={magic(4)}; c{:,:,2}={1:10}; d=cellfun(@(x) x{:},c,'uni',false) %{ d(:,:,1) = [4x4 double] d(:,:,2) = [1x10 double] %} us
From: Mano Samuel on 11 May 2010 22:12 "us " <us(a)neurol.unizh.ch> wrote in message <hsd1i9$nsk$1(a)fred.mathworks.com>... > "Mano Samuel" <manosamuel(a)rediffmail.com> wrote in message <hscvo5$1sn$1(a)fred.mathworks.com>... > > > > Hello, > > I have a variable x, > > x > > x(:,:,1) = > > {1x1 cell} > > x(:,:,2) = > > {1x1 cell} > > x(:,:,3) = > > {1x1 cell} > > x(:,:,4) = > > {1x1 cell} > > I would like to convert it and assign it to another variable 'data' as follows, > > data > > data(:,:,1) = > > [12x10 double] > > data(:,:,2) = > > [12x6 double] > > data(:,:,3) = > > [12x8 double] > > data(:,:,4) = > > [12x7 double] > > I am currently getting it done with the help of a FOR loop. is there a way to get the same done avoiding the FOR loop. > > > > x{:} , provides me with the desired value , but i'm not able to assign each individual cell to data without the help of a FOR loop. Hoping someone can help me out. > > Thank you. > > one of the solutions > > clear c d; % <- save old stuff! > c{:,:,1}={magic(4)}; > c{:,:,2}={1:10}; > d=cellfun(@(x) x{:},c,'uni',false) > %{ > d(:,:,1) = > [4x4 double] > d(:,:,2) = > [1x10 double] > %} > > us Thank you. It is a pity I could not come up with one among the many solutions available.
From: Mano Samuel on 12 May 2010 02:12 "Mano Samuel" <manosamuel(a)rediffmail.com> wrote in message <hsd2pk$am0$1(a)fred.mathworks.com>... > "us " <us(a)neurol.unizh.ch> wrote in message <hsd1i9$nsk$1(a)fred.mathworks.com>... > > "Mano Samuel" <manosamuel(a)rediffmail.com> wrote in message <hscvo5$1sn$1(a)fred.mathworks.com>... > > > > > > Hello, > > > I have a variable x, > > > x > > > x(:,:,1) = > > > {1x1 cell} > > > x(:,:,2) = > > > {1x1 cell} > > > x(:,:,3) = > > > {1x1 cell} > > > x(:,:,4) = > > > {1x1 cell} > > > I would like to convert it and assign it to another variable 'data' as follows, > > > data > > > data(:,:,1) = > > > [12x10 double] > > > data(:,:,2) = > > > [12x6 double] > > > data(:,:,3) = > > > [12x8 double] > > > data(:,:,4) = > > > [12x7 double] > > > I am currently getting it done with the help of a FOR loop. is there a way to get the same done avoiding the FOR loop. > > > > > > x{:} , provides me with the desired value , but i'm not able to assign each individual cell to data without the help of a FOR loop. Hoping someone can help me out. > > > Thank you. > > > > one of the solutions > > > > clear c d; % <- save old stuff! > > c{:,:,1}={magic(4)}; > > c{:,:,2}={1:10}; > > d=cellfun(@(x) x{:},c,'uni',false) > > %{ > > d(:,:,1) = > > [4x4 double] > > d(:,:,2) = > > [1x10 double] > > %} > > > > us > > Thank you. It is a pity I could not come up with one among the many solutions available. In the process of learning to use cellfun, I tried to concatenate each row within a cell, I used the following command, For example, let us assume, data(1,:,1) = [1 2 3 4 5 6 7 8 9 0]; data(1,:,2) = [1 2 3 4 5 6 ]; data(1,:,3) = [1 2 3 4 5 6 7 8]; data(1,:,4) = [1 2 3 4 5 6 7]; So i'd like the answer to be, ans = [1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7]; so i tried, sxd = cellfun(@(y) y(1,:,:),data,'uni',false) This provides, sxd(:,:,1) = [1x10 double] sxd(:,:,2) = [1x6 double] sxd(:,:,3) = [1x8 double] sxd(:,:,4) = [1x7 double] I am stuck here. not sure how to proceed further. us ? . Thank you.
From: Mano Samuel on 12 May 2010 02:30 "Mano Samuel" <manosamuel(a)rediffmail.com> wrote in message <hsdgrj$bqi$1(a)fred.mathworks.com>... > "Mano Samuel" <manosamuel(a)rediffmail.com> wrote in message <hsd2pk$am0$1(a)fred.mathworks.com>... > > "us " <us(a)neurol.unizh.ch> wrote in message <hsd1i9$nsk$1(a)fred.mathworks.com>... > > > "Mano Samuel" <manosamuel(a)rediffmail.com> wrote in message <hscvo5$1sn$1(a)fred.mathworks.com>... > > > > > > > > Hello, > > > > I have a variable x, > > > > x > > > > x(:,:,1) = > > > > {1x1 cell} > > > > x(:,:,2) = > > > > {1x1 cell} > > > > x(:,:,3) = > > > > {1x1 cell} > > > > x(:,:,4) = > > > > {1x1 cell} > > > > I would like to convert it and assign it to another variable 'data' as follows, > > > > data > > > > data(:,:,1) = > > > > [12x10 double] > > > > data(:,:,2) = > > > > [12x6 double] > > > > data(:,:,3) = > > > > [12x8 double] > > > > data(:,:,4) = > > > > [12x7 double] > > > > I am currently getting it done with the help of a FOR loop. is there a way to get the same done avoiding the FOR loop. > > > > > > > > x{:} , provides me with the desired value , but i'm not able to assign each individual cell to data without the help of a FOR loop. Hoping someone can help me out. > > > > Thank you. > > > > > > one of the solutions > > > > > > clear c d; % <- save old stuff! > > > c{:,:,1}={magic(4)}; > > > c{:,:,2}={1:10}; > > > d=cellfun(@(x) x{:},c,'uni',false) > > > %{ > > > d(:,:,1) = > > > [4x4 double] > > > d(:,:,2) = > > > [1x10 double] > > > %} > > > > > > us > > > > Thank you. It is a pity I could not come up with one among the many solutions available. > > > In the process of learning to use cellfun, I tried to concatenate each row within a cell, > I used the following command, > > For example, let us assume, > > data(1,:,1) = [1 2 3 4 5 6 7 8 9 0]; > data(1,:,2) = [1 2 3 4 5 6 ]; > data(1,:,3) = [1 2 3 4 5 6 7 8]; > data(1,:,4) = [1 2 3 4 5 6 7]; > > So i'd like the answer to be, > > ans = [1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7]; > > so i tried, > > sxd = cellfun(@(y) y(1,:,:),data,'uni',false) > > This provides, > > sxd(:,:,1) = > [1x10 double] > sxd(:,:,2) = > [1x6 double] > sxd(:,:,3) = > [1x8 double] > sxd(:,:,4) = > [1x7 double] > > I am stuck here. not sure how to proceed further. us ? . Thank you. nevermind. horzcat([sxd{:}]) does the trick.
|
Next
|
Last
Pages: 1 2 Prev: problems in trying ieee 802.15.4 working from msk Next: integral of arbitrary vector y |